Skip to content

Commit f30bcb5

Browse files
committed
feat: Added action to update the screenshots + process comment
1 parent b25dfc0 commit f30bcb5

File tree

1 file changed

+62
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)