Skip to content

Commit 3f716c3

Browse files
Phlogistiqueclaude
andcommitted
Recommend GitHub App token to fix CI not triggering on upstack PRs
Pushes made with the default GITHUB_TOKEN don't trigger workflow runs (GitHub's infinite-loop prevention). This means CI never runs on upstack PRs after autorestack pushes the synthetic merge commit, so they can't become mergeable if branch protection requires status checks. The setup instructions now walk users through creating a GitHub App and using actions/create-github-app-token to get an installation token. The old GITHUB_TOKEN approach is preserved in a collapsed section for repos that don't need CI on upstack PRs. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 8cc3a4f commit 3f716c3

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

README.md

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,50 @@ The action manages branch deletion itself. GitHub's auto-delete setting must be
5757
gh api -X PATCH "/repos/OWNER/REPO" --input - <<< '{"delete_branch_on_merge":false}'
5858
```
5959

60-
**2. Add the workflow**
60+
**2. Create a GitHub App**
61+
62+
When autorestack pushes the synthetic merge commit to upstack branches, you probably want CI to run on those PRs so they can become mergeable. Pushes made with the default `GITHUB_TOKEN` [do not trigger workflow runs](https://docs.github.com/en/actions/security-guides/automatic-token-authentication#using-the-github_token-in-a-workflow) — this is a deliberate GitHub limitation to prevent infinite loops. A GitHub App installation token does not have this limitation.
63+
64+
1. [Create a GitHub App](https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app) with the following repository permissions:
65+
- **Contents:** Read and write (to push branches)
66+
- **Pull requests:** Read and write (to update PRs, add labels, post comments)
67+
2. Install the app on your repository
68+
3. Store the App ID in a repository variable (e.g. `AUTORESTACK_APP_ID`)
69+
4. Generate a private key and store it in a repository secret (e.g. `AUTORESTACK_PRIVATE_KEY`)
70+
71+
**3. Add the workflow**
6172

6273
Create a `.github/workflows/update-pr-stack.yml` file:
6374
```yaml
6475
name: Update PR Stack
6576

77+
on:
78+
pull_request:
79+
types: [closed, synchronize]
80+
81+
jobs:
82+
update-pr-stack:
83+
runs-on: ubuntu-latest
84+
steps:
85+
- uses: actions/create-github-app-token@v2
86+
id: app-token
87+
with:
88+
app-id: ${{ vars.AUTORESTACK_APP_ID }}
89+
private-key: ${{ secrets.AUTORESTACK_PRIVATE_KEY }}
90+
91+
- uses: Phlogistique/autorestack-action@main
92+
with:
93+
github-token: ${{ steps.app-token.outputs.token }}
94+
```
95+
96+
<details>
97+
<summary>Using <code>GITHUB_TOKEN</code> instead (CI won't trigger on upstack PRs)</summary>
98+
99+
If you don't need CI checks on upstack PRs — for example, if your repository has no branch protection rules requiring status checks — you can use the default token:
100+
101+
```yaml
102+
name: Update PR Stack
103+
66104
on:
67105
pull_request:
68106
types: [closed, synchronize]
@@ -80,6 +118,8 @@ jobs:
80118
github-token: ${{ secrets.GITHUB_TOKEN }}
81119
```
82120
121+
</details>
122+
83123
### Notes
84124
85125
* Currently only supports squash merges

action.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ author: 'GitHub Actions'
44

55
inputs:
66
github-token:
7-
description: 'GitHub token for API access'
7+
description: >
8+
Token for git push and GitHub API calls. The default GITHUB_TOKEN will NOT
9+
trigger CI on upstack PRs (GitHub deliberately suppresses workflow runs from
10+
pushes made with that token). Use a GitHub App installation token if you need
11+
checks to run on the updated PRs.
812
required: true
913
default: ${{ github.token }}
1014

0 commit comments

Comments
 (0)