diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 665ac8d..8b87df6 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,6 +7,16 @@ on: # release.yml calls these jobs as its gates, since a tag does not start this workflow. workflow_call: +# A push to a pull request cancels that pull request's run still going, whose head is no longer +# the one to merge. Every run of one pull request shares the group, so a re-run of an older run +# cancels the current head's run too: re-run only the newest. Any other run is a group of its own +# (its run id), so a run on main and the jobs release.yml calls always finish; release.yml calls +# this workflow only off pull requests. github.workflow is the caller's name in a call, which +# would keep a future caller's pull request apart from this workflow's own. +concurrency: + group: ci-${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + jobs: build: name: build (${{ matrix.name }}) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8a0331f..7554936 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,9 +53,12 @@ on: permissions: contents: read +# A push to a pull request cancels that pull request's older run (re-run only the newest, since a +# re-run cancels the head's run too). A tag's or a dispatch's run is never cancelled while it +# runs, though a newer run on the same ref replaces one still pending. concurrency: group: release-${{ github.ref }} - cancel-in-progress: false + cancel-in-progress: ${{ github.event_name == 'pull_request' }} jobs: version: