GitHub actions workflow for cancelling CI when a newer commit is pushed
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
name: Cancel | |
on: | |
push: | |
branches: | |
- main | |
- master | |
pull_request: | |
types: [opened, synchronize, reopened, ready_for_review] | |
jobs: | |
cancel: | |
name: 'Cancel Previous Runs' | |
runs-on: ubuntu-latest | |
# https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#permissions | |
# we only need actions write: | |
permissions: | |
actions: write | |
timeout-minutes: 3 | |
steps: | |
- uses: styfle/cancel-workflow-action@0.9.1 | |
with: | |
# Put in the filenames of whatever workflows you want to cancel when a newer commit is pushed: | |
workflow_id: CI.yml,docs.yml,doctests.yml,format-check.yml | |
access_token: ${{ github.token }} | |
# When this workflow runs on a branch, it will cancel all workflows (according to the names above) | |
# except for the latest ones. | |
all_but_latest: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment