1+ name : Update screenshot on comment
2+ on :
3+ issue_comment :
4+ types : [created]
5+ jobs :
6+ update-screenshots :
7+ name : Update Screenshot
8+ if : github.event.issue.pull_request && contains(github.event.comment.body, '/approve-snapshots')
9+ runs-on : ubuntu-latest
10+ permissions :
11+ contents : write
12+ pull-requests : write
13+ steps :
14+ - uses : xt0rted/pull-request-comment-branch@v3
15+ id : comment-branch
16+ - uses : actions/checkout@v4
17+ if : success()
18+ with :
19+ ref : ${{ steps.comment-branch.outputs.head_ref }}
20+ - name : Comment on PR with Playwright updates
21+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
22+ if : ${{ failure() && env.SNAPSHOT_DIFFERENCES == 'true' }}
23+ with :
24+ script : |
25+ const body = `### Updating snapshots. Click [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see the status.`;
26+
27+ await github.rest.issues.createComment({
28+ issue_number: context.issue.number,
29+ owner: context.repo.owner,
30+ repo: context.repo.repo,
31+ body: body,
32+ });
33+ - name : Install dependencies
34+ run : cd tests && npm ci
35+ - name : Setup Hugo
36+ uses : peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
37+ with :
38+ hugo-version : " 0.134.2"
39+ extended : true
40+ - name : Install Playwright browsers
41+ run : npx playwright install --with-deps
42+ - name : Run Playwright update snapshots
43+ id : test-visual
44+ run : make tests-update-screenshots
45+ - uses : actions/upload-artifact@v4
46+ id : artifact-upload
47+ with :
48+ name : screenshots
49+ path : tests/src/__screenshots__
50+ - name : Comment on PR with success
51+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
52+ with :
53+ script : |
54+ const body = `### Please download the artifacts [here](${{ steps.artifact-upload.outputs.artifact-url }}) and commit your updated screenshots.`;
55+
56+ await github.rest.issues.createComment({
57+ issue_number: context.issue.number,
58+ owner: context.repo.owner,
59+ repo: context.repo.repo,
60+ body: body,
61+ });
0 commit comments