From 14c04f87d6532c187e8a8a589c5c03551ef24fc0 Mon Sep 17 00:00:00 2001 From: Piotr Czeglik Date: Mon, 1 Jul 2024 18:38:56 +0200 Subject: [PATCH] ci: setup chromatic --- .github/actions/chromatic/action.yml | 33 ++++++++++++++++++++++++++++ .github/workflows/ci.yml | 5 +++++ .github/workflows/publish.yml | 5 +++++ 3 files changed, 43 insertions(+) create mode 100644 .github/actions/chromatic/action.yml diff --git a/.github/actions/chromatic/action.yml b/.github/actions/chromatic/action.yml new file mode 100644 index 0000000..4eb1800 --- /dev/null +++ b/.github/actions/chromatic/action.yml @@ -0,0 +1,33 @@ +name: deploy chromatic +description: Deploy storybook to Chromatic + +inputs: + TOKEN: + description: 'Chromatic token' + required: true + +runs: + using: 'composite' + + steps: + - name: Tests + run: yarn test-storybook:ci + shell: bash + + - name: Publish to Chromatic + if: github.ref != 'refs/heads/main' + uses: chromaui/action@v1 + with: + projectToken: ${{ inputs.TOKEN }} + buildScriptName: build-storybook + onlyChanged: true + exitOnceUploaded: true + + - name: Publish to Chromatic and auto accept changes + if: github.ref == 'refs/heads/main' + uses: chromaui/action@v1 + with: + projectToken: ${{ inputs.TOKEN }} + autoAcceptChanges: true + onlyChanged: true + exitOnceUploaded: true diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cfbc07c..20db6c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -54,3 +54,8 @@ jobs: - name: Typecheck run: yarn type-check + + - name: Chromatic + uses: ./.github/actions/chromatic + with: + TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6cb1393..e21ad49 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -61,3 +61,8 @@ jobs: GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} NPM_TOKEN: ${{ secrets.GH_TOKEN }} run: npx semantic-release + + - name: Chromatic + uses: ./.github/actions/chromatic + with: + TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}