Skip to content

Commit 37b30d4

Browse files
authored
ci: handle fork PRs in SKILL.md auto-commit (#227)
## Summary Fixes a bug introduced in #224 where the `check-skill` CI job would fail for fork PRs. ## Problem The auto-commit flow for stale SKILL.md uses a GitHub App token (`SENTRY_RELEASE_BOT`) to push commits back to the branch. This fails for fork PRs because: 1. **Secrets are unavailable** — GitHub does not expose repo secrets to `pull_request` workflows triggered from forks (security policy) 2. **No push access** — Even if the token were available, the GitHub App is installed on `getsentry/cli`, not the contributor's fork ## Fix - **Skip the token step** for fork PRs (conditional on `github.event.pull_request.head.repo.full_name == github.repository`) - **Fall back to `github.token`** for checkout when the app token isn't available - **Auto-commit** only when the app token was successfully obtained (same-repo PRs and push events) - **Fail with an actionable error** for fork PRs, asking the contributor to run `bun run generate:skill` locally
1 parent 213f68f commit 37b30d4

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ jobs:
4949
steps:
5050
- name: Get auth token
5151
id: token
52+
# Fork PRs don't have access to secrets, so this step is skipped
53+
if: github.event.pull_request.head.repo.full_name == github.repository || github.event_name != 'pull_request'
5254
uses: actions/create-github-app-token@v2.2.1
5355
with:
5456
app-id: ${{ vars.SENTRY_RELEASE_BOT_CLIENT_ID }}
5557
private-key: ${{ secrets.SENTRY_RELEASE_BOT_PRIVATE_KEY }}
5658
- uses: actions/checkout@v4
5759
with:
58-
token: ${{ steps.token.outputs.token }}
60+
token: ${{ steps.token.outputs.token || github.token }}
5961
ref: ${{ github.head_ref || github.ref_name }}
6062
- uses: oven-sh/setup-bun@v2
6163
- uses: actions/cache@v4
@@ -69,14 +71,19 @@ jobs:
6971
id: check
7072
run: bun run check:skill
7173
continue-on-error: true
72-
- name: Commit regenerated SKILL.md
73-
if: steps.check.outcome == 'failure'
74+
- name: Auto-commit regenerated SKILL.md
75+
if: steps.check.outcome == 'failure' && steps.token.outcome == 'success'
7476
run: |
7577
git config user.name "github-actions[bot]"
7678
git config user.email "github-actions[bot]@users.noreply.github.com"
7779
git add plugins/sentry-cli/skills/sentry-cli/SKILL.md
7880
git commit -m "chore: regenerate SKILL.md"
7981
git push
82+
- name: Fail for fork PRs with stale SKILL.md
83+
if: steps.check.outcome == 'failure' && steps.token.outcome != 'success'
84+
run: |
85+
echo "::error::SKILL.md is out of date. Run 'bun run generate:skill' locally and commit the result."
86+
exit 1
8087
8188
lint:
8289
name: Lint & Typecheck

0 commit comments

Comments
 (0)