Skip to content

Commit

Permalink
Update README and fix #34
Browse files Browse the repository at this point in the history
  • Loading branch information
thomwiggers committed Feb 15, 2021
1 parent a865dac commit e12516c
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion README.md
Expand Up @@ -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 cancelled leaving only this run.

Read more about the [Workflow Runs API](https://docs.github.com/en/rest/reference/actions#workflow-runs).

Expand Down Expand Up @@ -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/cancel-workflow-action@0.8.0
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
Expand Down

0 comments on commit e12516c

Please sign in to comment.