This repository has been archived by the owner on Dec 21, 2023. It is now read-only.
Merge branch 'staging' into feat/creator-tokens #8244
Workflow file for this run
This file contains 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 | |
on: push | |
concurrency: | |
group: chromatic-${{ github.event_name }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
deploy-to-chromatic: | |
name: Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set up repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # 👈 Required to retrieve git history | |
- name: Set up Node | |
uses: actions/setup-node@v2 | |
with: | |
node-version: 16.x | |
- uses: 8BitJonny/gh-get-current-pr@1.3.0 | |
id: PR | |
name: Check if we're in a PR | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
sha: ${{ github.event.pull_request.head.sha }} | |
filterOutClosed: true | |
- name: Find yarn cache | |
id: yarn-cache-path | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- name: Restore cache | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.yarn-cache-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: ${{ runner.os }}-yarn- | |
- name: Install dependencies | |
run: yarn install --immutable | |
- name: Build storybook | |
run: yarn build:next-storybook | |
- name: Publish to Chromatic | |
id: chromatic-output | |
uses: chromaui/action@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
storybookBuildDir: apps/storybook-react/storybook-static | |
- name: Format Storybook Preview URL | |
id: format-storybook-preview-url | |
uses: mad9000/actions-find-and-replace-string@2 | |
if: success() && steps.PR.outputs.number != '' | |
with: | |
source: ${{ steps.chromatic-output.outputs.storybookUrl }} | |
find: "iframe.html" | |
replace: "" | |
- name: Find PR Comment | |
uses: peter-evans/find-comment@v1 | |
if: success() && steps.PR.outputs.number != '' | |
id: existing-comment | |
with: | |
issue-number: ${{ steps.PR.outputs.number }} | |
body-includes: PR Preview - Storybook on Chromatic | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v1 | |
if: success() && steps.PR.outputs.number != '' | |
with: | |
comment-id: ${{ steps.existing-comment.outputs.comment-id }} | |
issue-number: ${{ steps.PR.outputs.number }} | |
edit-mode: replace | |
body: | | |
## PR Preview - Storybook on Chromatic | |
✅ Preview: <a href="${{steps.format-storybook-preview-url.outputs.value}}">The Storybook preview URL for this Pull Request</a> | |
✅ Build: <a href="${{ steps.chromatic-output.outputs.buildUrl}}"> The Chromatic build URL for this Pull Request</a> |