Save time and cost when using GitHub Actions
open sourceMITfree
skip-duplicate-actions is a GitHub Actions action, usually run in a small pre-job, whose should_skip output lets later jobs or steps skip work that has already been done. Through GitHub's Workflow Runs API it compares the current run with earlier runs of the same workflow: when one with the same tree hash (exactly the same files) already succeeded, as after a clean merge of a branch that passed, it skips. Its paths_ignore and paths options walk back through the commit history to the last commit with a successful run, and skip when everything changed since then is ignored or outside the paths, which works with required checks where GitHub's own path filters don't. It can also skip or cancel runs of the same workflow that are in progress or outdated, and paths_filter gives different jobs in one workflow their own named path rules (see also dorny/paths-filter, which compares against a base instead). Manual, scheduled and merge queue runs are never skipped by default.
Problems it solves
- don't rerun CI for a commit whose files are identical to one that already passed
- CI runs everything again after I merge a branch that already passed on the same code
- skip the slow tests for README and docs-only commits but keep them as a required check
- GitHub's paths-ignore leaves my required status check pending forever so the PR can't merge
- whether CI skips a path depends on whether I pushed the commits one at a time or together
- cancel the older workflow runs on a branch when I push a new commit
- a push and a pull_request trigger run the same workflow twice on the same commit
- my GitHub Actions minutes run out because every push runs every job, even docs-only commits
- skip a folder's tests unless something in that folder changed since the last green run
- show which earlier run already checked these exact files when a run is skipped
Features
- skips a run when a successful run of the same workflow has the same tree hash
- paths_ignore and paths backtrack to the last commit with a successful run
- paths_filter: named path rules per job, with a paths_result output
- concurrent_skipping: never, same_content, same_content_newer, outdated_runs or always
- cancel_others cancels runs for outdated commits
- do_not_skip names triggers never skipped (workflow_dispatch, schedule and merge_group by default)
- skipped_by and changed_files outputs name the matching run and what changed
- backtracking limit per filter
- works with fast-forward, rebase and squash merges
Limitations
- Doesn't track jobs one by one: it skips when an earlier run of the same whole workflow succeeded on the same files, found through GitHub's Workflow Runs API1
Alternatives
The same job
These do what fkirc/skip-duplicate-actions does.
- dorny/paths-filter Conditionally run actions based on files modified by PR, feature branch or pushed commits