Thoughts about a mimeType equivalent to text/uri-list #10
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 E2E Snapshots | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| branch: | |
| description: "Branch to update snapshots on" | |
| required: true | |
| default: "main" | |
| issue_comment: | |
| types: [created] | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| update-snapshots: | |
| # Run on workflow_dispatch OR when someone comments "/update-snapshots" on a PR | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event.issue.pull_request && contains(github.event.comment.body, '/update-snapshots')) | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Get PR branch | |
| if: github.event_name == 'issue_comment' | |
| id: pr | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const pr = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.issue.number | |
| }); | |
| core.setOutput('ref', pr.data.head.ref); | |
| core.setOutput('sha', pr.data.head.sha); | |
| - name: Add reaction to comment | |
| if: github.event_name == 'issue_comment' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.reactions.createForIssueComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: context.payload.comment.id, | |
| content: 'rocket' | |
| }); | |
| - uses: actions/checkout@v4 | |
| with: | |
| ref: ${{ github.event.inputs.branch || steps.pr.outputs.ref || github.ref }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| - uses: astral-sh/setup-uv@v5 | |
| - run: npm ci | |
| - name: Install Playwright browsers | |
| run: npx playwright install --with-deps chromium | |
| - name: Update snapshots | |
| run: npx playwright test --update-snapshots --reporter=list | |
| - name: Commit updated snapshots | |
| id: commit | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add tests/e2e/**/*.png | |
| if git diff --staged --quiet; then | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| echo "No snapshot changes to commit" | |
| else | |
| git commit -m "chore: update e2e snapshots [skip ci]" | |
| git push | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Comment on PR | |
| if: github.event_name == 'issue_comment' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const changed = '${{ steps.commit.outputs.changed }}' === 'true'; | |
| const body = changed | |
| ? '✅ Snapshots updated and pushed to this branch.' | |
| : '✅ No snapshot changes needed - all snapshots are up to date.'; | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| body | |
| }); |