feat: advanced state mapping support #2444
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: Pull Request | |
| on: | |
| pull_request: | |
| paths-ignore: | |
| - '.changeset/**' | |
| - '.husky/**' | |
| concurrency: | |
| group: ci-pull-request=${{github.ref}}-1 | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| statuses: write | |
| # Note: Canary publishing is handled by publish.yml workflow | |
| jobs: | |
| # This job exists only to satisfy branch protection rules that expect this check name | |
| # The actual publishing is done in publish.yml | |
| build-canary-status: | |
| name: 'Build & canary release' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Publishing handled by publish.yml | |
| run: echo "Canary publishing is handled by the Publish workflow (publish.yml)" | |
| tests: | |
| name: 'Tests & lint' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Update Corepack | |
| run: npm i -g corepack@latest | |
| - name: Enable Corepack (pre) | |
| run: corepack enable | |
| - name: Prepare pnpm (pre) | |
| run: corepack prepare [email protected] --activate | |
| - uses: actions/cache@v4 | |
| name: Download eslint cache | |
| with: | |
| path: | | |
| **/.eslintcache | |
| key: ${{ runner.os }}-eslint | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Prepare pnpm | |
| run: corepack prepare [email protected] --activate | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run the lint | |
| run: pnpm lint | |
| - name: Run the tests | |
| run: pnpm test:no-cache | |
| deploy-chromatic: | |
| name: 'Prepare Storybook for review & tests' | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: Chromatic staging | |
| url: ${{ steps.publish_chromatic.outputs.url }} | |
| env: | |
| CHROMATIC_RETRIES: 5 | |
| LOG_LEVEL: 'error' | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Update Corepack | |
| run: npm i -g corepack@latest | |
| - name: Enable Corepack (pre) | |
| run: corepack enable | |
| - name: Prepare pnpm (pre) | |
| run: corepack prepare [email protected] --activate | |
| - uses: actions/cache@v4 | |
| name: Download storybook cache | |
| with: | |
| path: | | |
| **/node_modules/.cache | |
| key: ${{ runner.os }}-storybook-${{ github.run_id }} | |
| restore-keys: | | |
| ${{ runner.os }}-storybook | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version-file: '.nvmrc' | |
| cache: 'pnpm' | |
| - name: Enable Corepack | |
| run: corepack enable | |
| - name: Prepare pnpm | |
| run: corepack prepare [email protected] --activate | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Publish to Chromatic | |
| id: publish_chromatic | |
| uses: chromaui/action@v11 | |
| with: | |
| exitZeroOnChanges: true | |
| exitOnceUploaded: true | |
| onlyChanged: true | |
| debug: true | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
| - name: Comment PR | |
| uses: actions/github-script@v6 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const setMessage = require('${{ github.workspace }}/scripts/ci/set-message.cjs') | |
| await setMessage({ | |
| header: "## 🧪 Storybook is successfully deployed!", | |
| body: ` | |
| - 👀 Review changes: ${{ steps.publish_chromatic.outputs.url }} | |
| - 👨🎨 Preview storybook: ${{ steps.publish_chromatic.outputs.storybookUrl }} | |
| `, | |
| github, | |
| repo: context.repo, | |
| prNumber: context.payload.pull_request.number | |
| }) |