Skip to content

Commit 78dd50f

Browse files
authored
ci(coverage): push refreshed map via GitHub App token (ruleset bypass) (#1465)
The default CACHE_PUSH_TOKEN could not push to master: the master repository ruleset requires PRs, and its bypass list only honors org-admins / repo-admin-role (not fine-grained PATs). Mint a short-lived installation token from the mfc-map-bot GitHub App (contents:write), which is now an Integration bypass actor on that ruleset, and push with it via actions/create-github-app-token@v3.
1 parent 475d320 commit 78dd50f

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

.github/workflows/coverage-refresh.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,30 @@ jobs:
2626
with: { clean: false }
2727
- name: Build + collect coverage map (SLURM)
2828
run: bash .github/scripts/submit-slurm-job.sh .github/workflows/common/coverage-refresh.sh cpu none phoenix
29+
# Mint a short-lived GitHub App installation token. The app is on the master
30+
# ruleset's bypass list (Integration actor), so its push satisfies the
31+
# "require pull request" rule that rejects the default GITHUB_TOKEN.
32+
- name: Generate app token
33+
id: app-token
34+
uses: actions/create-github-app-token@v3
35+
with:
36+
app-id: ${{ secrets.MAP_BOT_APP_ID }}
37+
private-key: ${{ secrets.MAP_BOT_APP_PRIVATE_KEY }}
2938
- name: Commit refreshed map
3039
env:
31-
CACHE_PUSH_TOKEN: ${{ secrets.CACHE_PUSH_TOKEN }}
40+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
3241
run: |
3342
if ! git diff --quiet tests/coverage_map.json.gz; then
34-
git config user.name "mfc-bot"
35-
git config user.email "mfc-bot@users.noreply.github.com"
43+
git config user.name "mfc-map-bot[bot]"
44+
git config user.email "mfc-map-bot[bot]@users.noreply.github.com"
3645
git add tests/coverage_map.json.gz
3746
# --no-verify: this bot commit stages only the binary coverage map; it
3847
# must not run the repo pre-commit hook (./mfc.sh precheck/spelling),
3948
# which is for source changes and aborts the commit on the runner.
4049
git commit --no-verify -m "test: refresh coverage map [skip ci]"
41-
# Push to protected master via CACHE_PUSH_TOKEN (a PAT/App token with
42-
# contents:write + branch-protection bypass), mirroring deploy-tap.yml's
43-
# x-access-token push. The default GITHUB_TOKEN is rejected by protection.
44-
git push "https://x-access-token:${CACHE_PUSH_TOKEN}@github.com/MFlowCode/MFC.git" HEAD:master
50+
# Push to master via the app installation token. The app is a bypass
51+
# actor on the master ruleset, so the require-PR rule does not reject it.
52+
git push "https://x-access-token:${GH_TOKEN}@github.com/MFlowCode/MFC.git" HEAD:master
4553
else
4654
echo "Coverage map unchanged."
4755
fi

0 commit comments

Comments
 (0)