Chromatic for pull requests #899
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: Chromatic for pull requests | |
| on: | |
| workflow_run: | |
| workflows: | |
| # On PR, to trigger visual regression testing | |
| - Continuous Integration | |
| # On push to main, to set new baseline | |
| - publish | |
| types: | |
| - completed | |
| permissions: | |
| # Read the contents of the repo | |
| contents: read | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.event.workflow_run.head_branch }} | |
| cancel-in-progress: true | |
| jobs: | |
| chromatic: | |
| # Only run if the Continuous Integration workflow was successful | |
| if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| # Use the correct ref to check out | |
| ref: ${{ github.event.workflow_run.head_sha }} | |
| # Make sure that history is available to Chromatic | |
| fetch-depth: 0 | |
| - name: Install pnpm package manager | |
| uses: pnpm/action-setup@41ff72655975bd51cab0327fa583b6e92b6d3061 # v4.2.0 | |
| - name: Set up Node.js version and cache | |
| uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0 | |
| with: | |
| node-version-file: .nvmrc | |
| - name: Check for known security issues with npm packages | |
| run: | | |
| echo "Auditing dependencies. For more information, see: https://nldesignsystem.nl/pnpm-audit" | |
| pnpm audit --audit-level critical | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Download visual-regression-testing artifact | |
| uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0 | |
| with: | |
| name: visual-regression-testing | |
| # Needed to download an artifact created in a different workflow | |
| github-token: ${{ github.token }} | |
| run-id: ${{ github.event.workflow_run.id }} | |
| path: packages/storybook-test/dist/ | |
| - name: Chromatic | |
| uses: chromaui/action@07791f8243f4cb2698bf4d00426baf4b2d1cb7e0 # v13.3.5 | |
| with: | |
| autoAcceptChanges: main | |
| projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
| storybookBaseDir: packages/storybook-test/ | |
| storybookBuildDir: packages/storybook-test/dist/ | |
| storybookConfigDir: packages/storybook-test/config/ | |
| exitOnceUploaded: true | |
| onlyChanged: true |