Skip to content

Commit 1111111

Browse files
jlsajfjclaude
andcommitted
Feat: route-sync uses a GitHub App token for fetch + CI-triggering PR
A single App credential covers both halves: read the private backend manifest and open a PR here that actually triggers CI (default GITHUB_TOKEN PRs don't run checks, so the drift guard would never go red). Mint the installation token in-workflow via actions/create-github-app-token scoped to both repos; job no-ops until SYNC_APP_ID + SYNC_APP_PRIVATE_KEY are set. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent effe84d commit 1111111

1 file changed

Lines changed: 27 additions & 14 deletions

File tree

.github/workflows/route-sync.yml

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,56 @@
11
name: Route Sync
22

33
# Opens a PR when the backend's canonical v2 route manifest drifts from the
4-
# vendored copy; the PR then fails test_route_coverage until the matching SDK
5-
# methods + `# v2:covers` comments are added. demo2 is private, so fetching its
6-
# manifest needs a token with Contents:read on it — store it as the
7-
# BACKEND_REPO_TOKEN secret (fine-grained PAT scoped to demo2, or a GitHub App
8-
# installation token).
4+
# vendored copy; that PR fails test_route_coverage until the matching SDK
5+
# methods + `# v2:covers` comments are added.
6+
#
7+
# Auth: a GitHub App is the single credential for both halves — it reads the
8+
# private backend repo's manifest AND opens a PR here that triggers CI (PRs from
9+
# the default GITHUB_TOKEN do not run checks). Configure:
10+
# - var SYNC_APP_ID, secret SYNC_APP_PRIVATE_KEY
11+
# - install the App on the backend repo (Contents: read) and on this repo
12+
# (Contents: read/write, Pull requests: read/write)
13+
# Until configured the job no-ops.
914

1015
on:
1116
schedule:
1217
- cron: "0 12 * * *"
1318
workflow_dispatch:
1419

1520
permissions:
16-
contents: write
17-
pull-requests: write
21+
contents: read
1822

1923
jobs:
2024
sync:
2125
runs-on: ubuntu-latest
2226
env:
23-
GH_TOKEN: ${{ secrets.BACKEND_REPO_TOKEN }}
24-
BACKEND_REPO: ${{ vars.BACKEND_REPO || 'TextQLLabs/demo2' }}
27+
BACKEND_REPO_NAME: ${{ vars.BACKEND_REPO_NAME || 'demo2' }}
2528
MANIFEST_PATH: ${{ vars.BACKEND_MANIFEST_PATH || 'compute/pkg/platform/v2/routes.manifest.json' }}
2629
MANIFEST_REF: ${{ vars.BACKEND_MANIFEST_REF || 'main' }}
2730
steps:
2831
- uses: actions/checkout@v4
32+
- name: Mint App token
33+
id: app-token
34+
if: ${{ vars.SYNC_APP_ID != '' }}
35+
uses: actions/create-github-app-token@v1
36+
with:
37+
app-id: ${{ vars.SYNC_APP_ID }}
38+
private-key: ${{ secrets.SYNC_APP_PRIVATE_KEY }}
39+
repositories: |
40+
${{ vars.BACKEND_REPO_NAME || 'demo2' }}
41+
${{ github.event.repository.name }}
2942
- name: Fetch upstream manifest
3043
id: fetch
44+
env:
45+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3146
run: |
3247
set -euo pipefail
3348
if [ -z "${GH_TOKEN:-}" ]; then
34-
echo "BACKEND_REPO_TOKEN not set; skipping"
49+
echo "GitHub App not configured (set SYNC_APP_ID + SYNC_APP_PRIVATE_KEY); skipping"
3550
echo "changed=false" >> "$GITHUB_OUTPUT"
3651
exit 0
3752
fi
38-
gh api "repos/${BACKEND_REPO}/contents/${MANIFEST_PATH}?ref=${MANIFEST_REF}" \
53+
gh api "repos/${{ github.repository_owner }}/${BACKEND_REPO_NAME}/contents/${MANIFEST_PATH}?ref=${MANIFEST_REF}" \
3954
-H "Accept: application/vnd.github.raw" > upstream.json
4055
changed=$(python3 -c "import json; a=set(json.load(open('upstream.json'))); b=set(json.load(open('tests/routes.manifest.json'))); print('true' if a!=b else 'false')")
4156
if [ "$changed" = "true" ]; then cp upstream.json tests/routes.manifest.json; fi
@@ -44,9 +59,7 @@ jobs:
4459
if: steps.fetch.outputs.changed == 'true'
4560
uses: peter-evans/create-pull-request@v6
4661
with:
47-
# Default GITHUB_TOKEN-created PRs do NOT trigger CI; pass a PAT/App
48-
# token here if you want test_route_coverage to run automatically.
49-
token: ${{ secrets.ROUTE_SYNC_PR_TOKEN || secrets.GITHUB_TOKEN }}
62+
token: ${{ steps.app-token.outputs.token }}
5063
branch: route-sync
5164
add-paths: tests/routes.manifest.json
5265
commit-message: "chore: sync v2 route manifest from backend"

0 commit comments

Comments
 (0)