ci: Add reusable wait-for-check workflow to safely trigger release

Introduces a reusable workflow that waits until the 'Check' workflow has successfully passed on the current commit.

Also adds 'release-trigger', which runs on push to main and calls this reusable workflow before allowing semantic-release to continue.

- Prevents race conditions between quality checks and release
- No external dependencies (uses native GitHub CLI)
- Improves reliability and control of CI/CD sequencing
This commit is contained in:
Digikwal 2025-06-26 17:14:42 +02:00 committed by GitHub
parent e15b9247d0
commit d54fbd96cc
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

52
.github/workflows/wait-for-check.yml vendored Normal file
View file

@ -0,0 +1,52 @@
name: Wait for Check Workflow
on:
workflow_call:
inputs:
sha:
required: true
type: string
secrets:
GH_TOKEN:
required: true
jobs:
wait-for-check:
runs-on: ubuntu-latest
steps:
- name: Wait for Check workflow to succeed
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
SHA: ${{ inputs.sha }}
run: |
echo "🔁 Waiting for 'Check' workflow to succeed on commit $SHA..."
max_attempts=30
attempt=1
interval=10
success=false
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt..."
status=$(gh run list --workflow "Check" --limit 1 --json status,conclusion,headSha -q \
'map(select(.headSha=="'"$SHA"'")) | .[0] | "\(.status)-\(.conclusion)"')
if [[ "$status" == "completed-success" ]]; then
echo "✅ Check passed."
success=true
break
elif [[ "$status" == completed-* ]]; then
echo "❌ Check completed but failed."
exit 1
else
echo "⏳ Still in progress..."
sleep $interval
((attempt++))
fi
done
if [[ "$success" == false ]]; then
echo "❌ Timeout: Check workflow did not complete in time."
exit 1
fi