Skip to content

Commit e345a70

Browse files
committed
ci(rebase-stack): use STACK_REBASE_TOKEN so rebased pushes trigger CI
## Summary `.github/workflows/rebase-stack.yml` was authenticating with the default `GITHUB_TOKEN` for both `actions/checkout` (which configures git credentials for the push) and the `gh` CLI. Pushes made with `GITHUB_TOKEN` are intentionally ignored by GitHub's workflow trigger (anti-recursion protection), so the force-pushed rebased branch never fired `pull_request.synchronize` and CI did not run on the rebased PR. The repo already has a `STACK_REBASE_TOKEN` secret holding a personal access token but it was not referenced anywhere. ### Changes - `actions/checkout@v4` now passes `token: ${{ secrets.STACK_REBASE_TOKEN }}` so `git push --force-with-lease` is attributed to a user. - `GH_TOKEN` is set to the same secret so `gh pr edit` / `gh pr comment` are also user-attributed. - Removed the `gh api .../check-suites` POST workaround. It was a band-aid for the `GITHUB_TOKEN` limitation and would now create a duplicate empty check suite alongside the real `pull_request.synchronize` run. ## Test Plan - ✅ `make fmt` and `make lint` clean. - Workflow change is exercised on PR merge; will be validated when the next stacked PR is merged and CI fires on the rebased child PR. ## Issues
1 parent 5b94eef commit e345a70

1 file changed

Lines changed: 7 additions & 8 deletions

File tree

.github/workflows/rebase-stack.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,16 @@ jobs:
5757
with:
5858
# Fetch full history so rebase --onto works correctly.
5959
fetch-depth: 0
60+
# Use a personal access token (stored as STACK_REBASE_TOKEN) so the
61+
# force-push below is attributed to a user and triggers downstream
62+
# workflows (CI). Pushes authenticated with the default GITHUB_TOKEN
63+
# are intentionally ignored by GitHub's workflow trigger to prevent
64+
# recursive runs, which would leave rebased PRs without a CI signal.
65+
token: ${{ secrets.STACK_REBASE_TOKEN }}
6066

6167
- name: Rebase stacked PRs
6268
env:
63-
GH_TOKEN: ${{ github.token }}
69+
GH_TOKEN: ${{ secrets.STACK_REBASE_TOKEN }}
6470
MERGED_HEAD: ${{ github.event.pull_request.head.ref }}
6571
MERGED_BASE: ${{ github.event.pull_request.base.ref }}
6672
MERGED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
@@ -198,13 +204,6 @@ jobs:
198204
return 1
199205
fi
200206
201-
# Pushes made with GITHUB_TOKEN don't trigger other workflows
202-
# (GitHub's anti-recursion protection). Explicitly request a
203-
# check suite so CI runs on the rebased branch.
204-
echo " requesting check suite for CI"
205-
gh api "repos/${GITHUB_REPOSITORY}/check-suites" \
206-
-X POST -f "head_sha=${new_child_tip}" --silent || true
207-
208207
# Point the PR at the correct base branch in GitHub.
209208
gh pr edit "$pr_number" --base "$new_pr_base"
210209
echo " PR #${pr_number} base updated to '${new_pr_base}'."

0 commit comments

Comments
 (0)