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.
How does it work?
The action stores the information in a folder that is also a branch, using a git worktree.
It wraps the run like this:
-
state
branch is checked out as a worktree under a folder named.state
(which must be ignored by.gitignore
). Please checkscripts/main.sh
. - The application writes its state into the
.state
folder. - Changes in
state
branch are commited and pushed to origin. Please checkscripts/post.sh
:- Changes are commited and pushed.
- Old commits on
state
branch are squashed and force-pushed. -
.state
worktree is removed.
For more details, please check the repository.
Top comments (0)