ci: finalize mark-stable workflow fixes

- use correct GitHub API path (/repos/.../actions/runs)
- resolve repository via workflow_run.repository.full_name
- improve logging and safe no-tag exits
- ensure correct token handling and tag update logic

https://chatgpt.com/share/693aa4a6-7460-800f-ba47-cfc15b1b2236
This commit is contained in:
Kevin Veen-Birkenbach
2025-12-11 12:38:12 +01:00
parent 3218b2b39f
commit e9e083c9dd

View File

@@ -28,7 +28,7 @@ jobs:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
fetch-depth: 0 # required for accessing tags/history fetch-depth: 0 # needed for tag operations
- name: Install jq and gh (if needed) - name: Install jq and gh (if needed)
run: | run: |
@@ -44,7 +44,8 @@ jobs:
run: | run: |
set -euo pipefail set -euo pipefail
echo "Checking workflow results for commit: $SHA in repository: $REPO" echo "Checking workflow results for commit: $SHA"
echo "Repository: $REPO"
required_workflows=( required_workflows=(
"Test Units" "Test Units"
@@ -55,9 +56,11 @@ jobs:
"Test Virgin Root" "Test Virgin Root"
) )
# Fetch all workflow runs for this commit echo "Fetching workflow runs via GitHub API…"
# FIXED: correct absolute API path
json=$(gh api \ json=$(gh api \
repos/"$REPO"/actions/runs \ /repos/"$REPO"/actions/runs \
-F head_sha="$SHA" \ -F head_sha="$SHA" \
-F per_page=100) -F per_page=100)
@@ -69,17 +72,19 @@ jobs:
' | head -n1) ' | head -n1)
if [[ -z "$conclusion" || "$conclusion" == "null" ]]; then if [[ -z "$conclusion" || "$conclusion" == "null" ]]; then
echo "Workflow '$wf' has no run for this commit yet. Exiting without tagging." echo "Workflow '$wf' has no run for this commit yet. Not tagging."
exit 0 exit 0
fi fi
if [[ "$conclusion" != "success" ]]; then if [[ "$conclusion" != "success" ]]; then
echo "Workflow '$wf' did not succeed (conclusion='$conclusion'). Exiting without tagging." echo "Workflow '$wf' did not succeed (status: $conclusion). Not tagging."
exit 0 exit 0
fi fi
echo "✔ Workflow '$wf' succeeded."
done done
echo "All required workflows succeeded for commit $SHA — marking as stable." echo "🎉 All required workflows succeeded for commit $SHA — marking as stable."
- name: Move 'stable' tag to this commit - name: Move 'stable' tag to this commit
env: env:
@@ -90,12 +95,18 @@ jobs:
git config user.name "github-actions[bot]" git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com" git config user.email "github-actions[bot]@users.noreply.github.com"
echo "Updating 'stable' tag to point to $SHA" echo "Updating 'stable' tag → commit $SHA"
# remove old tag locally
if git rev-parse stable >/dev/null 2>&1; then if git rev-parse stable >/dev/null 2>&1; then
git tag -d stable || true git tag -d stable || true
fi fi
# delete remote tag if exists
git push origin :refs/tags/stable || true git push origin :refs/tags/stable || true
# create new tag
git tag stable "$SHA" git tag stable "$SHA"
git push origin stable git push origin stable
echo "✅ Stable tag updated successfully."