|
| 1 | +# Note: Chromatic is a separate workflow for coder.yaml as suggested by the |
| 2 | +# chromatic docs. Explicitly, Chromatic works best on 'push' instead of other |
| 3 | +# event types (like pull request), keep in mind that it works build-over-build |
| 4 | +# by storing snapshots. |
| 5 | +# |
| 6 | +# SEE: https://www.chromatic.com/docs/ci |
| 7 | +name: "Chromatic" |
| 8 | + |
| 9 | +# Chromatic works best with push events, not pull_request or other event types. |
| 10 | +on: push |
| 11 | + |
| 12 | +jobs: |
| 13 | + chromatic-deployment: |
| 14 | + # REMARK: this is only used to build storybook and deploy it to Chromatic. |
| 15 | + runs-on: ubuntu-latest |
| 16 | + |
| 17 | + steps: |
| 18 | + - uses: actions/checkout@v3 |
| 19 | + with: |
| 20 | + # Required by Chromatic for build-over-build history, otherwise we |
| 21 | + # only get 1 commit on shallow checkout. |
| 22 | + fetch-depth: 0 |
| 23 | + |
| 24 | + - name: Install dependencies |
| 25 | + run: cd site && yarn |
| 26 | + |
| 27 | + # This step is not meant for mainline because any detected changes to |
| 28 | + # storybook snapshots will require manual approval/review in order for |
| 29 | + # the check to pass. This is desired in PRs, but not in mainline. |
| 30 | + - name: Publish to Chromatic (non-mainline) |
| 31 | + if: github.ref != 'refs/heads/main' |
| 32 | + uses: chromaui/action@v1 |
| 33 | + with: |
| 34 | + buildScriptName: "storybook:build" |
| 35 | + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} |
| 36 | + workingDir: "./site" |
| 37 | + |
| 38 | + # This is a separate step for mainline only that auto accepts and changes |
| 39 | + # instead of holding CI up. Since we squash/merge, this is defensive to |
| 40 | + # avoid the same changeset from requiring review once squashed into |
| 41 | + # main. Chromatic is supposed to be able to detect that we use squash |
| 42 | + # commits, but it's good to be defensive in case, otherwise CI remains |
| 43 | + # infinitely "in progress" in mainline unless we re-review each build. |
| 44 | + - name: Publish to Chromatic (mainline) |
| 45 | + if: github.ref == 'refs/heads/main' |
| 46 | + uses: chromaui/action@v1 |
| 47 | + with: |
| 48 | + autoAcceptChanges: true |
| 49 | + buildScriptName: "storybook:build" |
| 50 | + projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} |
| 51 | + workingDir: "./site" |
0 commit comments