Skip to content

Commit 0d93e9b

Browse files
authored
ci: move chromatic to coder workflow (#3330)
1 parent 19fcf60 commit 0d93e9b

File tree

2 files changed

+50
-68
lines changed

2 files changed

+50
-68
lines changed

.github/workflows/chromatic.yaml

Lines changed: 0 additions & 68 deletions
This file was deleted.

.github/workflows/coder.yaml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
outputs:
5252
docs-only: ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
5353
sh: ${{ steps.filter.outputs.sh }}
54+
ts: ${{ steps.filter.outputs.ts }}
5455
steps:
5556
- uses: actions/checkout@v3
5657
# For pull requests it's not necessary to checkout the code
@@ -66,6 +67,11 @@ jobs:
6667
# - '.github/**'
6768
sh:
6869
- "**.sh"
70+
ts:
71+
- "**.tsx?"
72+
- "**.jsx?"
73+
- "**.lock"
74+
- "**.json"
6975
- id: debug
7076
run: |
7177
echo "${{ toJSON(steps.filter )}}"
@@ -623,3 +629,47 @@ jobs:
623629
DD_CATEGORY: e2e
624630
GIT_COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
625631
run: go run scripts/datadog-cireport/main.go site/test-results/junit.xml
632+
chromatic:
633+
# REMARK: this is only used to build storybook and deploy it to Chromatic.
634+
runs-on: ubuntu-latest
635+
needs:
636+
- changes
637+
if: needs.changes.outputs.ts == 'true'
638+
steps:
639+
- uses: actions/checkout@v3
640+
with:
641+
# Required by Chromatic for build-over-build history, otherwise we
642+
# only get 1 commit on shallow checkout.
643+
fetch-depth: 0
644+
645+
- name: Install dependencies
646+
run: cd site && yarn
647+
648+
# This step is not meant for mainline because any detected changes to
649+
# storybook snapshots will require manual approval/review in order for
650+
# the check to pass. This is desired in PRs, but not in mainline.
651+
- name: Publish to Chromatic (non-mainline)
652+
if: github.ref != 'refs/heads/main' && github.repository_owner == 'coder'
653+
uses: chromaui/action@v1
654+
with:
655+
buildScriptName: "storybook:build"
656+
exitOnceUploaded: true
657+
# Chromatic states its fine to make this token public. See:
658+
# https://www.chromatic.com/docs/github-actions#forked-repositories
659+
projectToken: 695c25b6cb65
660+
workingDir: "./site"
661+
662+
# This is a separate step for mainline only that auto accepts and changes
663+
# instead of holding CI up. Since we squash/merge, this is defensive to
664+
# avoid the same changeset from requiring review once squashed into
665+
# main. Chromatic is supposed to be able to detect that we use squash
666+
# commits, but it's good to be defensive in case, otherwise CI remains
667+
# infinitely "in progress" in mainline unless we re-review each build.
668+
- name: Publish to Chromatic (mainline)
669+
if: github.ref == 'refs/heads/main' && github.repository_owner == 'coder'
670+
uses: chromaui/action@v1
671+
with:
672+
autoAcceptChanges: true
673+
buildScriptName: "storybook:build"
674+
projectToken: 695c25b6cb65
675+
workingDir: "./site"

0 commit comments

Comments
 (0)