Skip to content

Commit 3b30c18

Browse files
jbachorikclaude
andcommitted
Fix upstream tracker workflow to handle Actions variable permission errors gracefully
The workflow was failing when trying to update the UPSTREAM_LAST_COMMIT Actions variable due to insufficient permissions (403 error). This commit makes the update step non-fatal by: 1. Adding continue-on-error: true to prevent workflow failure 2. Restructuring the update logic to provide clear warnings 3. Exiting with status 1 on permission error (caught by continue-on-error) The workflow will now succeed even if it cannot persist state between runs. When permissions are insufficient, it will emit warnings explaining: - The permission issue - That the workflow will use current HEAD as baseline - That a repository admin needs to configure Actions permissions This allows the workflow to remain functional for change detection and issue creation, even without the ability to persist the last checked commit. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 99a50ae commit 3b30c18

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

.github/workflows/upstream-tracker.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,27 @@ jobs:
120120
121121
- name: Update last checked commit
122122
if: success() && steps.clone-upstream.outcome == 'success'
123+
continue-on-error: true
123124
env:
124125
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
125126
run: |
126-
gh api \
127+
# Try to update the variable, but don't fail the workflow if we can't
128+
if gh api \
127129
--method PATCH \
128130
repos/${{ github.repository }}/actions/variables/UPSTREAM_LAST_COMMIT \
129131
-f value="${UPSTREAM_HEAD}" \
130-
2>/dev/null || \
131-
gh api \
132+
2>/dev/null; then
133+
echo "Updated last checked commit to ${UPSTREAM_HEAD}"
134+
elif gh api \
132135
--method POST \
133136
repos/${{ github.repository }}/actions/variables \
134137
-f name=UPSTREAM_LAST_COMMIT \
135-
-f value="${UPSTREAM_HEAD}"
136-
137-
echo "Updated last checked commit to ${UPSTREAM_HEAD}"
138+
-f value="${UPSTREAM_HEAD}" \
139+
2>/dev/null; then
140+
echo "Created last checked commit variable with value ${UPSTREAM_HEAD}"
141+
else
142+
echo "::warning::Unable to persist last checked commit. This may be due to insufficient repository Actions permissions."
143+
echo "::warning::The workflow will continue to work but will always compare from the current HEAD as baseline."
144+
echo "::warning::To enable state persistence, a repository admin needs to configure Actions permissions."
145+
exit 1
146+
fi

0 commit comments

Comments
 (0)