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
+ with :
23
+ script : |
24
+ const body = `### Updating snapshots. Click [here](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}) to see the status.`;
25
+
26
+ await github.rest.issues.createComment({
27
+ issue_number: context.issue.number,
28
+ owner: context.repo.owner,
29
+ repo: context.repo.repo,
30
+ body: body,
31
+ });
32
+ - name : Setup Hugo
33
+ uses : peaceiris/actions-hugo@75d2e84710de30f6ff7268e08f310b60ef14033f # v3.0.0
34
+ with :
35
+ hugo-version : " 0.134.2"
36
+ extended : true
37
+ - name : Install dependencies and Playwright browsers
38
+ run : cd tests && npm ci && npx playwright install --with-deps
39
+ - name : Run Playwright update snapshots
40
+ id : test-visual
41
+ run : make tests-update-screenshots
42
+ - uses : actions/upload-artifact@v4
43
+ id : artifact-upload
44
+ with :
45
+ name : screenshots
46
+ path : tests/src/__screenshots__
47
+ - name : Comment on PR with success
48
+ uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
49
+ with :
50
+ script : |
51
+ const body = `### Please download the artifacts [here](${{ steps.artifact-upload.outputs.artifact-url }}) and commit your updated screenshots.`;
52
+
53
+ await github.rest.issues.createComment({
54
+ issue_number: context.issue.number,
55
+ owner: context.repo.owner,
56
+ repo: context.repo.repo,
57
+ body: body,
58
+ });
0 commit comments