fix: use bot token for issue creation and link PRs to tracking issues
Three fixes in the upstream-sync workflow: 1. Replace github.token with CLAUDE_BOT_TOKEN in the check-upstream job. The default runner token on Forgejo doesn't have issue-write permissions, so issues were silently failing to create. 2. Output the tracking issue number from check-upstream and pass it to the merge-upstream job. Claude's prompt now includes the issue reference and instructs it to add "Closes #N" in the PR body. 3. Capture the issue number from both create and update paths so the merge job always has it available. Also cleaned up 6 duplicate upstream-sync labels created by previous runs that used the unprivileged token. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc063f62f0
commit
88e7747d2f
2 files changed
+29
-14
No files matched your search
@@ -18,6 +18,7 @@ jobs:
|
||||
needs_sync: ${{ steps.compare.outputs.needs_sync }}
|
||||
behind: ${{ steps.compare.outputs.behind }}
|
||||
ahead: ${{ steps.compare.outputs.ahead }}
|
||||
issue_number: ${{ steps.sync-issue.outputs.issue_number }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: https://${{ secrets.READ_REPO_TOKEN }}@git.wxs.ro/xternal/checkout@v6.0.2
|
||||
@@ -72,7 +73,7 @@ jobs:
|
||||
id: existing
|
||||
run: |-
|
||||
RESPONSE=$(curl -s \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Authorization: token ${{ secrets.CLAUDE_BOT_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues?state=open&labels=upstream-sync&limit=1")
|
||||
|
||||
@@ -92,12 +93,13 @@ jobs:
|
||||
run: |-
|
||||
curl -s -o /dev/null -w "%{http_code}" \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Authorization: token ${{ secrets.CLAUDE_BOT_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"name":"upstream-sync","color":"#0075ca","description":"Upstream sync tracking"}' \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/labels" || true
|
||||
- name: Create or update sync issue
|
||||
if: steps.compare.outputs.needs_sync == 'true'
|
||||
id: sync-issue
|
||||
run: |-
|
||||
BEHIND="${{ steps.compare.outputs.behind }}"
|
||||
AHEAD="${{ steps.compare.outputs.ahead }}"
|
||||
@@ -156,19 +158,22 @@ jobs:
|
||||
ISSUE_NUMBER="${{ steps.existing.outputs.issue_number }}"
|
||||
curl -s -o /dev/null \
|
||||
-X PATCH \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Authorization: token ${{ secrets.CLAUDE_BOT_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg title "$TITLE" --arg body "$BODY" '{title: $title, body: $body}')" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}"
|
||||
echo "Updated existing issue #${ISSUE_NUMBER}"
|
||||
echo "issue_number=${ISSUE_NUMBER}" >> "$GITHUB_OUTPUT"
|
||||
else
|
||||
curl -s -o /dev/null \
|
||||
RESPONSE=$(curl -s \
|
||||
-X POST \
|
||||
-H "Authorization: token ${{ github.token }}" \
|
||||
-H "Authorization: token ${{ secrets.CLAUDE_BOT_TOKEN }}" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "$(jq -n --arg title "$TITLE" --arg body "$BODY" '{title: $title, body: $body, labels: [{"name": "upstream-sync"}]}')" \
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues"
|
||||
echo "Created new upstream sync issue"
|
||||
"${{ env.GITHUB_API_URL }}/repos/${{ github.repository }}/issues")
|
||||
ISSUE_NUMBER=$(echo "$RESPONSE" | jq '.number')
|
||||
echo "Created new upstream sync issue #${ISSUE_NUMBER}"
|
||||
echo "issue_number=${ISSUE_NUMBER}" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
merge-upstream:
|
||||
name: Auto-merge Upstream
|
||||
@@ -258,6 +263,7 @@ jobs:
|
||||
## Current state
|
||||
- Branch: ${{ steps.prepare.outputs.branch }}
|
||||
- ${{ needs.check-upstream.outputs.behind }} commits behind upstream, ${{ needs.check-upstream.outputs.ahead }} commits ahead (our Forgejo changes)
|
||||
- Tracking issue: #${{ needs.check-upstream.outputs.issue_number }}
|
||||
- Merge was attempted. Status: ${{ steps.prepare.outputs.merge_clean }} (true = clean, false = has conflicts)
|
||||
|
||||
## Impact analysis
|
||||
@@ -293,6 +299,7 @@ jobs:
|
||||
Auth: token $GITHUB_TOKEN
|
||||
Title: "chore: merge ${{ needs.check-upstream.outputs.behind }} upstream commits from anthropics/claude-code-action"
|
||||
Body should include:
|
||||
- "Closes #${{ needs.check-upstream.outputs.issue_number }}" on its own line (links PR to the tracking issue)
|
||||
- Summary of notable upstream changes
|
||||
- Impact assessment: which fork files (if any) were affected
|
||||
- List of conflicts resolved (if any)
|
||||
|
||||
Reference in new issue
Block a user