ci: publish PR screenshots to a ci-screenshots branch

A separate job with write access downloads the screenshots artifact and
force-pushes it as a single commit, so screens can be reviewed with a
plain git fetch. The build job keeps read-only permissions; forks are
skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 11:21:54 +00:00
1 parent ea3de59c72
commit 9b006a9fcf
2 files changed
+24

No files matched your search

+23
View File
@@ -137,6 +137,29 @@ jobs:
path: out/publish/
retention-days: 14
screenshots:
name: Screenshots branch
# Same-repository pull requests only: forks never get a writable token.
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: screenshots
path: screenshots
- name: Publish to the ci-screenshots branch (one commit, overwritten each run)
working-directory: screenshots
run: |
git init -q -b ci-screenshots
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add -A
git commit -q -m "Screenshots of ${{ github.event.pull_request.head.sha }}"
git push -q -f "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}.git" HEAD:refs/heads/ci-screenshots
postgres:
name: PostgreSQL ${{ matrix.pg }} integration
strategy: