03 - Update Snapshots #1389
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: 03 - Update Snapshots | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| delete_snapshots: | |
| description: 'Delete existing snapshots before update?' | |
| required: false | |
| default: false | |
| type: boolean | |
| concurrency: | |
| group: 'workflow-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}' | |
| cancel-in-progress: true | |
| jobs: | |
| update-snapshots: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/create-github-app-token@v3 | |
| id: app-token | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.PRIVATE_KEY }} | |
| - name: Get GitHub App User ID | |
| id: get-user-id | |
| run: echo "user-id=$(gh api "/users/${{ steps.app-token.outputs.app-slug }}[bot]" --jq .id)" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ steps.app-token.outputs.token }} | |
| - name: Checkout branch | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.ref_name }} | |
| token: ${{ steps.app-token.outputs.token }} | |
| # https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time | |
| - name: Install Node.js | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| id: pnpm-install | |
| with: | |
| version: 10 | |
| run_install: false | |
| - name: Get pnpm store directory | |
| id: pnpm-cache | |
| shell: bash | |
| run: echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store | |
| - name: Install | |
| run: pnpm i --no-frozen-lockfile | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps firefox | |
| - name: Build | |
| run: pnpm --filter @public-ui/sample-react^... build | |
| - name: Purge existing snapshots (optional) | |
| if: inputs.delete_snapshots == true | |
| run: find packages -name '*.png' -path '*/snapshots/*' | grep -v 'node_modules' | xargs rm # Remove any existing snapshots, except those in node_modules | |
| - name: Display git status (before test-update) | |
| run: git status | |
| - name: Run snapshot updates | |
| run: pnpm test:update | |
| - name: Display git status (after test-update) | |
| run: git status | |
| - name: Stage snapshot changes | |
| run: find packages \( -path '*/node_modules' -prune \) -o \( -path '*/__snapshots__/*' -o -path '*/snapshots/*' \) -print | xargs --no-run-if-empty git add -- | |
| - name: Commit and push changes | |
| uses: stefanzweifel/git-auto-commit-action@v7 | |
| with: | |
| commit_message: Update all snapshots | |
| commit_user_name: '${{ steps.app-token.outputs.app-slug }}[bot]' | |
| commit_user_email: '${{ steps.get-user-id.outputs.user-id }}+${{ steps.app-token.outputs.app-slug }}[bot]@users.noreply.github.com' |