This is my entry for the GitHub Actions Hackathon on DEV:
💾 Stateful Action persists the data into a branch after every run, letting the actions keep a state between runs.
I use this utility to periodically run reports, crawlers, and bots that live entirely as a GitHub repository. They keep the state of the progress in a branch. Some of them store the information in a SQLite database file. I also the action for publishing the results in the GitHub pages branch.
The action squashes the oldest commits, so the repository size doesn't grow wildly.
The action stores the information in a folder that is also a branch, using a git worktree.
It wraps the run like this:
statebranch is checked out as a worktree under a folder named
.state(which must be ignored by
.gitignore). Please check
- The application writes its state into the
- Changes in
statebranch are commited and pushed to origin. Please check
- Changes are commited and pushed.
- Old commits on
statebranch are squashed and force-pushed.
.stateworktree is removed.
For more details, please check the repository.