- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optionally cancel all workflows but the latest (#35)
* Cancel all workflows but the latest Co-authored-by: Steven <[email protected]>
1 parent
3d86a7c
commit 1adde81
Showing
3 changed files
with
53 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ This includes runs with a [status](https://docs.github.com/en/rest/reference/che | |
|
||
## How does it work? | ||
|
||
When you `git push`, this GitHub Action will capture the current Branch and SHA. It will query GitHub's API to find previous workflow runs that match the Branch but do not match the SHA. These in-progress runs will be canceled leaving only the latest run. | ||
When you `git push`, this GitHub Action will capture the current Branch and SHA. It will query GitHub's API to find previous workflow runs that match the Branch but do not match the SHA. These in-progress runs will be canceled leaving only this run. | ||
|
||
Read more about the [Workflow Runs API](https://docs.github.com/en/rest/reference/actions#workflow-runs). | ||
|
||
|
@@ -100,6 +100,28 @@ jobs: | |
workflow_id: 479426 | ||
``` | ||
|
||
## Advanced: Cancel more recent workflows | ||
|
||
Because this action can only cancel workflows if it is actually being run, it only helps if the pipeline isn't saturated and there are still runners available to schedule the workflow. | ||
By default, this action does not cancel any workflows older than itself. The optional flag ``all_but_latest`` switches to a mode where the action also cancels itself and all later-scheduled workflows but the last one. | ||
|
||
```yml | ||
name: Cancel | ||
on: [push] | ||
jobs: | ||
cancel: | ||
name: 'Cancel Previous Runs' | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 3 | ||
steps: | ||
- uses: styfle/[email protected] | ||
with: | ||
all_but_latest: true | ||
access_token: ${{ github.token }} | ||
``` | ||
|
||
At the time of writing `0.8.0` is the latest release but you can select any [release](https://github.com/styfle/cancel-workflow-action/releases). | ||
|
||
## Contributing | ||
|
||
- Clone this repo | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters