Skip to content

Commit d9ce4b4

Browse files
JOYclaude
andcommitted
fix(ci): use gh api for release creation to fix workflow scope error
gh release create in Actions fails with "workflow scope may be required" even with a PAT that has workflow scope. Switch to gh api direct call which bypasses gh CLI's token resolution issues. Also remove GITHUB_TOKEN fallback to fail early if GH_PAT is not set. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 6e89f09 commit d9ce4b4

1 file changed

Lines changed: 21 additions & 7 deletions

File tree

.github/workflows/sync-upstream.yml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,20 +135,34 @@ jobs:
135135
- name: Create release
136136
if: steps.target.outputs.skip == 'false' && steps.merge.outputs.result == 'success'
137137
env:
138-
GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
138+
GH_TOKEN: ${{ secrets.GH_PAT }}
139139
run: |
140140
TAG="${{ steps.target.outputs.tag }}"
141+
142+
# Verify PAT is available (not falling back to GITHUB_TOKEN)
143+
if [ -z "$GH_TOKEN" ]; then
144+
echo "::error::GH_PAT secret is not set. Cannot create release without workflow scope."
145+
exit 1
146+
fi
147+
141148
# Delete existing release if any (from upstream fork sync)
142-
gh release delete "$TAG" --yes 2>/dev/null || true
143-
gh release create "$TAG" \
144-
--title "DOScan $TAG" \
145-
--notes "Synced from upstream [blockscout/blockscout $TAG](https://github.com/blockscout/blockscout/releases/tag/$TAG)" \
146-
--latest
149+
RELEASE_ID=$(gh api "repos/${{ github.repository }}/releases/tags/$TAG" --jq '.id' 2>/dev/null || true)
150+
if [ -n "$RELEASE_ID" ]; then
151+
echo "Deleting existing release $RELEASE_ID for $TAG"
152+
gh api -X DELETE "repos/${{ github.repository }}/releases/$RELEASE_ID" 2>/dev/null || true
153+
fi
154+
155+
# Create release via API (more reliable than gh release create in Actions)
156+
gh api "repos/${{ github.repository }}/releases" \
157+
-f tag_name="$TAG" \
158+
-f name="DOScan $TAG" \
159+
-f body="Synced from upstream [blockscout/blockscout $TAG](https://github.com/blockscout/blockscout/releases/tag/$TAG)" \
160+
-F make_latest=true
147161
148162
- name: Create PR on conflict
149163
if: steps.target.outputs.skip == 'false' && steps.merge.outputs.result == 'conflict'
150164
env:
151-
GH_TOKEN: ${{ secrets.GH_PAT || secrets.GITHUB_TOKEN }}
165+
GH_TOKEN: ${{ secrets.GH_PAT }}
152166
run: |
153167
TAG="${{ steps.target.outputs.tag }}"
154168
BRANCH="sync-upstream-${TAG}"

0 commit comments

Comments
 (0)