Skip to content

Commit 7cabb00

Browse files
authored
Merge pull request #9 from eurosky-social/quentin/sync-upstream-app-token
ci: use GitHub App token to push sync branch (workflow files)
2 parents 00def14 + 6f1f37e commit 7cabb00

1 file changed

Lines changed: 20 additions & 7 deletions

File tree

.github/workflows/sync-upstream.yaml

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ name: Sync from upstream
88
# Requirements:
99
# - An `upstream` reference to bluesky-social/atproto. This workflow adds it at
1010
# runtime, so no remote config is needed in the repo.
11-
#
12-
# Note on tokens/CI: the PR is opened with the default GITHUB_TOKEN, which by
13-
# design does NOT trigger the `on: pull_request` CI in repo.yaml. That is fine
14-
# here because the PR is opened as a draft (we don't want CI yet). When a human
15-
# marks it "Ready for review", that human-triggered `ready_for_review` event
16-
# does start CI. So no GitHub App / PAT is needed.
11+
# - A GitHub App installed on this repo with these repository permissions:
12+
# * Contents: Read and write (push the sync branch)
13+
# * Pull requests: Read and write (open the PR)
14+
# * Workflows: Read and write (REQUIRED: the sync branch carries
15+
# .github/workflows/* changes from upstream, and the
16+
# default GITHUB_TOKEN is categorically forbidden from
17+
# pushing workflow files)
18+
# Store the App ID in the `SYNC_UPSTREAM_APP_ID` repository variable and the
19+
# private key in the `SYNC_UPSTREAM_PK` secret.
1720

1821
on:
1922
workflow_dispatch:
@@ -35,11 +38,21 @@ jobs:
3538
sync:
3639
runs-on: ubuntu-latest
3740
steps:
41+
- name: Generate GitHub App token
42+
id: app-token
43+
uses: actions/create-github-app-token@v1
44+
with:
45+
app-id: ${{ vars.SYNC_UPSTREAM_APP_ID }}
46+
private-key: ${{ secrets.SYNC_UPSTREAM_PK }}
47+
3848
- name: Checkout main (full history)
3949
uses: actions/checkout@v4
4050
with:
4151
ref: main
4252
fetch-depth: 0
53+
# App token is required to push the sync branch, which contains
54+
# .github/workflows/* changes that GITHUB_TOKEN may not write.
55+
token: ${{ steps.app-token.outputs.token }}
4356

4457
- name: Add upstream and fetch
4558
run: |
@@ -96,7 +109,7 @@ jobs:
96109

97110
- name: Open pull request
98111
env:
99-
GH_TOKEN: ${{ github.token }}
112+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
100113
BRANCH: ${{ steps.branch.outputs.name }}
101114
UPSTREAM_REF: ${{ github.event.inputs.upstream_ref }}
102115
CONFLICTS: ${{ steps.merge.outputs.conflicts }}

0 commit comments

Comments
 (0)