-
-
Notifications
You must be signed in to change notification settings - Fork 259
65 lines (59 loc) · 2.31 KB
/
update-visual-screenshots.yml
File metadata and controls
65 lines (59 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
name: Update Visual Regression Screenshots
on:
workflow_dispatch:
permissions:
contents: write
jobs:
Update_Visual_Screenshots:
runs-on: ubuntu-latest
container:
# Keep this image tag aligned with package.json's playwright version.
image: mcr.microsoft.com/playwright:v1.59.1-noble
steps:
- name: Refuse default branch
if: github.ref_name == github.event.repository.default_branch
run: |
echo "Visual screenshot baselines must be updated from a feature branch."
exit 1
- name: Checkout
uses: actions/checkout@v6.0.2
with:
ref: ${{ github.ref }}
- name: Setup Node.js environment
uses: actions/setup-node@v6.3.0
with:
node-version-file: ".node-version"
cache: yarn
- name: Enable Corepack
run: corepack enable
- name: Install dependencies
run: yarn
- name: Build ReScript
run: yarn build:res
- name: Update visual screenshot baselines
run: yarn workspace @rescript-lang/docs ci:test:visual:update
- name: Commit changed baselines
id: commit-baselines
run: |
git add apps/docs/__tests__/visual/__screenshots__
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No visual screenshot baseline changes were produced." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git commit \
-m "test: update visual regression screenshots" \
-m "Updated from the GitHub Actions visual baseline workflow."
echo "changed=true" >> "$GITHUB_OUTPUT"
- name: Push changed baselines
if: steps.commit-baselines.outputs.changed == 'true'
run: git push origin HEAD:${{ github.ref_name }}
- name: Summarize changed baselines
if: steps.commit-baselines.outputs.changed == 'true'
run: |
echo "## Visual screenshot baseline changes" >> "$GITHUB_STEP_SUMMARY"
echo "" >> "$GITHUB_STEP_SUMMARY"
git diff --name-only HEAD~1 HEAD -- apps/docs/__tests__/visual/__screenshots__ \
| sed 's/^/- /' >> "$GITHUB_STEP_SUMMARY"