Skip to content

Update Asciidoc Contributors #289

Update Asciidoc Contributors

Update Asciidoc Contributors #289

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@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3.5.3
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@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: '18'
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@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3.0.2
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.' }}