fix: resolve CI run detection issues in release workflow

- Add 'actions: read' permission to access workflow runs
- Use workflow name instead of filename for gh run list
- Look for CI run on HEAD~1 (before version bump commit)
- Improve error messages for better debugging

Fixes HTTP 403 error when trying to find successful CI runs
This commit is contained in:
Andy Lee
2025-07-24 14:27:26 -07:00
parent 50686c0819
commit 9076bc27b8

View File

@@ -18,6 +18,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions: permissions:
contents: write contents: write
actions: read
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
@@ -67,10 +68,10 @@ jobs:
- name: Get CI run ID - name: Get CI run ID
id: get-ci-run id: get-ci-run
run: | run: |
# Get the latest successful CI run on this commit # Get the latest successful CI run on the previous commit (before version bump)
COMMIT_SHA=$(git rev-parse HEAD) COMMIT_SHA=$(git rev-parse HEAD~1)
RUN_ID=$(gh run list \ RUN_ID=$(gh run list \
--workflow=ci.yml \ --workflow="CI - Build and Test" \
--status=success \ --status=success \
--commit=$COMMIT_SHA \ --commit=$COMMIT_SHA \
--json databaseId \ --json databaseId \
@@ -78,7 +79,12 @@ jobs:
if [ -z "$RUN_ID" ]; then if [ -z "$RUN_ID" ]; then
echo "❌ No successful CI run found for commit $COMMIT_SHA" echo "❌ No successful CI run found for commit $COMMIT_SHA"
echo "Please wait for CI to complete before releasing." echo ""
echo "This usually means:"
echo "1. CI hasn't run on the latest commit yet"
echo "2. CI failed on the latest commit"
echo ""
echo "Please ensure CI passes on main branch before releasing."
exit 1 exit 1
fi fi