Skip to content

Commit 6155b7a

Browse files
authored
fix(workflow): use app token for gh variable set — GITHUB_TOKEN lacks permission (#7771)
## Summary Fix `ci-poller.yml` failing with `HTTP 403: Resource not accessible by integration` when calling `gh variable set CI_POLLER_HAS_PENDING`. Failing run: https://github.com/getsentry/publish/actions/runs/24263308562/job/70852292016 ## Root Cause `GITHUB_TOKEN` cannot write repo variables through the Actions Variables API, even with `actions: write` in the workflow permissions block. The sentry-internal-app token has admin access and can write variables. PR #7768 incorrectly assumed the opposite (that the app token lacked permission and `GITHUB_TOKEN` had it). ## Changes - `ci-poller.yml`: "Disable poller" step uses app token instead of `GITHUB_TOKEN` - `ci-pending.yml`: "Enable cron poller" step uses app token instead of `GITHUB_TOKEN` - Remove unnecessary `actions: write` from both workflow permission blocks
1 parent 526f721 commit 6155b7a

2 files changed

Lines changed: 7 additions & 9 deletions

File tree

.github/workflows/ci-pending.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
permissions:
88
contents: read
99
issues: read
10-
actions: write
1110

1211
jobs:
1312
mark-pending:
@@ -33,8 +32,8 @@ jobs:
3332
3433
- name: Enable cron poller
3534
env:
36-
# Use GITHUB_TOKEN (with actions:write) for variable access —
37-
# the app token may not have the actions_variables permission.
38-
GH_TOKEN: ${{ github.token }}
35+
# Use the app token — GITHUB_TOKEN cannot write repo variables
36+
# (403 "Resource not accessible by integration").
37+
GH_TOKEN: ${{ steps.token.outputs.token }}
3938
run: |
4039
gh variable set CI_POLLER_HAS_PENDING -R "$GITHUB_REPOSITORY" -b "true"

.github/workflows/ci-poller.yml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ on:
77
permissions:
88
contents: read
99
issues: read
10-
actions: write
1110

1211
jobs:
1312
check-ci:
@@ -140,16 +139,16 @@ jobs:
140139
fi
141140
done
142141
143-
# Disable the poller if no ci-pending issues remain. Uses GITHUB_TOKEN
144-
# (with actions:write) since the app token may lack actions_variables
145-
# permission.
142+
# Disable the poller if no ci-pending issues remain.
146143
# Note: there's a small race window where ci-pending.yml could set the
147144
# variable to "true" right before we set it to "false" here. In that case
148145
# the new issue waits at most one cron tick (5 min) — ci-pending.yml will
149146
# set the variable again on the next issue:opened event if needed.
150147
- name: Disable poller if no pending issues remain
151148
env:
152-
GH_TOKEN: ${{ github.token }}
149+
# Use the app token — GITHUB_TOKEN cannot write repo variables
150+
# (403 "Resource not accessible by integration").
151+
GH_TOKEN: ${{ steps.token.outputs.token }}
153152
run: |
154153
remaining=$(gh issue list -R "$GITHUB_REPOSITORY" \
155154
--state open \

0 commit comments

Comments
 (0)