Skip to content

Commit 85780fc

Browse files
committed
ci: skip release run if another is already in progress
1 parent 26f892c commit 85780fc

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,24 @@ jobs:
2121
version: ${{ steps.v.outputs.version }}
2222
tag: ${{ steps.v.outputs.tag }}
2323
steps:
24+
- name: Skip if another release run is already in progress
25+
env:
26+
GH_TOKEN: ${{ github.token }}
27+
SELF_ID: ${{ github.run_id }}
28+
REPO: ${{ github.repository }}
29+
shell: bash
30+
run: |
31+
set -euo pipefail
32+
others=$(gh run list -R "$REPO" --workflow=release.yml --status=in_progress \
33+
--json databaseId --jq ".[] | select(.databaseId != ${SELF_ID}) | .databaseId" \
34+
|| true)
35+
if [ -n "$others" ]; then
36+
echo "::notice title=Release skipped::another release run is already in progress ($others); cancelling self"
37+
gh run cancel "$SELF_ID" -R "$REPO" || true
38+
# Block until the cancel takes effect so downstream jobs don't run.
39+
sleep 120
40+
exit 1
41+
fi
2442
- uses: actions/checkout@v4
2543
- id: v
2644
shell: bash

0 commit comments

Comments
 (0)