Skip to content

Commit bd39e06

Browse files
mmuckloclaude
andcommitted
Fix screenshot loop: push to orphan ref instead of PR branch
Committing screenshots to the PR branch caused an infinite loop (PNG diffs on every run). Now screenshots are pushed to a separate orphan ref (refs/screenshots/{branch}) which doesn't trigger CI and doesn't pollute the PR branch. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 819ed04 commit bd39e06

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

.github/workflows/ci.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,6 @@ jobs:
9999
steps:
100100
- name: Checkout
101101
uses: actions/checkout@v4
102-
with:
103-
ref: ${{ github.head_ref || github.ref_name }}
104-
token: ${{ secrets.GITHUB_TOKEN }}
105102

106103
- name: Setup PHP
107104
uses: shivammathur/setup-php@v2
@@ -134,30 +131,33 @@ jobs:
134131
name: grid-screenshots
135132
path: Tests/Screenshots/output/*.png
136133

137-
- name: Commit screenshots to branch
134+
- name: Push screenshots to separate ref
138135
run: |
136+
SCREENSHOTS_REF="refs/screenshots/${{ github.head_ref || github.ref_name }}"
139137
git config user.name "github-actions[bot]"
140138
git config user.email "github-actions[bot]@users.noreply.github.com"
141-
git add -f Tests/Screenshots/output/*.png
142-
git diff --staged --quiet && echo "No screenshot changes" && exit 0
143-
git commit -m "Update grid screenshots"
144-
git push
139+
git checkout --orphan screenshots-tmp
140+
git rm -rf . > /dev/null 2>&1
141+
cp Tests/Screenshots/output/*.png .
142+
git add *.png
143+
git commit -m "Grid screenshots for ${{ github.head_ref || github.ref_name }}"
144+
git push origin HEAD:${SCREENSHOTS_REF} --force
145145
146146
- name: Comment on PR with screenshots
147147
if: github.event_name == 'pull_request'
148148
env:
149149
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150150
run: |
151151
REPO="${{ github.repository }}"
152-
BRANCH="${{ github.head_ref }}"
153-
SHA=$(git rev-parse HEAD)
154-
BODY="## Grid Screenshots ($(date -u +%Y-%m-%d))
152+
SCREENSHOTS_REF="refs/screenshots/${{ github.head_ref }}"
153+
REF_SHA=$(git rev-parse HEAD)
154+
BODY="## Grid Screenshots
155155
156156
**Table renderer:**
157-
![table](https://raw.githubusercontent.com/${REPO}/${SHA}/Tests/Screenshots/output/table.png)
157+
![table](https://raw.githubusercontent.com/${REPO}/${REF_SHA}/table.png)
158158
159159
**DataTables renderer:**
160-
![datatables](https://raw.githubusercontent.com/${REPO}/${SHA}/Tests/Screenshots/output/datatables.png)
160+
![datatables](https://raw.githubusercontent.com/${REPO}/${REF_SHA}/datatables.png)
161161
162162
_Auto-generated from [CI run](https://github.com/${REPO}/actions/runs/${{ github.run_id }})_"
163163

0 commit comments

Comments
 (0)