Update Vitest #13
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Update Visual Regression Screenshots | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| types: [labeled] | |
| env: | |
| AUTHOR_NAME: 'github-actions[bot]' | |
| AUTHOR_EMAIL: '41898282+github-actions[bot]@users.noreply.github.com' | |
| COMMIT_MESSAGE: | | |
| test: update visual regression screenshots | |
| Co-authored-by: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | |
| jobs: | |
| update-screenshots: | |
| # don't run on main | |
| if: ${{ github.event.label.name == 'Update Screenshots' && github.ref_name != 'main' }} | |
| runs-on: ubuntu-latest | |
| # one at a time per branch | |
| concurrency: | |
| group: visual-regression-screenshots@${{ github.ref_name }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write # needs to push changes | |
| steps: | |
| - uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 | |
| - uses: actions/setup-node@a0853c24544627f65ddf259abe73b1d18a591444 | |
| with: | |
| node-version: 24 | |
| check-latest: true | |
| - name: Remove label | |
| uses: actions-ecosystem/action-remove-labels@2ce5d41b4b6aa8503e285553f75ed56e0a40bae0 | |
| with: | |
| labels: 'Update Screenshots' | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Configure Git | |
| run: | | |
| git config --global user.name "${{ env.AUTHOR_NAME }}" | |
| git config --global user.email "${{ env.AUTHOR_EMAIL }}" | |
| - name: npm install | |
| run: npm i | |
| - name: Install Playwright Browsers | |
| run: npx playwright install chromium | |
| - name: Update Visual Regression Screenshots | |
| run: node --run visual:update | |
| # check what changed | |
| - name: Check for changes | |
| id: check_changes | |
| run: | | |
| CHANGED_FILES=$(git status --porcelain | awk '{print $2}') | |
| if [ "${CHANGED_FILES:+x}" ]; then | |
| echo "changes=true" >> $GITHUB_OUTPUT | |
| echo "Changes detected" | |
| # save the list for the summary | |
| echo "changed_files<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGED_FILES" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "changed_count=$(echo "$CHANGED_FILES" | wc -l)" >> $GITHUB_OUTPUT | |
| else | |
| echo "changes=false" >> $GITHUB_OUTPUT | |
| echo "No changes detected" | |
| fi | |
| # commit if there are changes | |
| - name: Commit changes | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: | | |
| git add -A | |
| git commit -m "${{ env.COMMIT_MESSAGE }}" | |
| - name: Push changes | |
| if: steps.check_changes.outputs.changes == 'true' | |
| run: git push origin ${{ github.ref_name }} | |
| # pretty summary for humans | |
| - name: Summary | |
| run: | | |
| if [[ "${{ steps.check_changes.outputs.changes }}" == "true" ]]; then | |
| echo "### 📸 Visual Regression Screenshots Updated" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Successfully updated **${{ steps.check_changes.outputs.changed_count }}** screenshot(s) on \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "#### Changed Files:" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "${{ steps.check_changes.outputs.changed_files }}" >> $GITHUB_STEP_SUMMARY | |
| echo "\`\`\`" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "✅ The updated screenshots have been committed and pushed. Your visual regression baseline is now up to date!" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "### ℹ️ No Screenshot Updates Required" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "The visual regression test command ran successfully but no screenshots needed updating." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "All screenshots are already up to date! 🎉" >> $GITHUB_STEP_SUMMARY | |
| fi |