-
-
Notifications
You must be signed in to change notification settings - Fork 117
49 lines (42 loc) · 1.54 KB
/
update_snapshot.yml
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
name: Update Vitest Snapshots
on:
issue_comment:
types: [created]
jobs:
update-snapshots:
runs-on: ubuntu-latest
if: startsWith(github.event.comment.body, '/update-snapshot')
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
ref: ${{ github.event.issue.head_ref }}
repository: ${{ github.event.issue.repository.full_name }}
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm install
- name: Update Vitest Snapshots
run: npm test -- -u
- name: Commit and push changes
run: |
git config --global user.name "GitHub Action"
git config --global user.email "action@github.com"
git add .
if git diff-index --quiet HEAD; then
echo "NO_CHANGES_DETECTED=1" >> "${GITHUB_ENV}"
else
git commit -m "Update Vitest Snapshots"
git push
fi
- name: Add comment
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0
with:
token: ${{ secrets.GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
body: |
${{ env.NO_CHANGES_DETECTED == '1' && 'No snapshot changes detected.' || 'Snapshots updated and changes pushed to the PR.' }}