Skip to content

Instantly share code, notes, and snippets.

@wladpaiva
Last active July 13, 2023 14:50
Show Gist options
  • Save wladpaiva/e2f593ee0e9d2fd12380bfa6932fb453 to your computer and use it in GitHub Desktop.
Save wladpaiva/e2f593ee0e9d2fd12380bfa6932fb453 to your computer and use it in GitHub Desktop.
turbo-ignore steps on GitHub Action
name: "Chromatic Publish"
on: push
jobs:
# @see https://www.chromatic.com/docs/github-actions#support-for-codeactionscheckoutv2code-and-above
chromatic-deployment:
# Don't need to run if this is a dependency update
# if: ${{ github.actor != 'dependabot[bot]' }}
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v3
with:
fetch-depth: 0 # 👈 Required to retrieve git history
- name: 🟨 Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- name: ⎔ Setup node
uses: actions/setup-node@v3
with:
node-version: 18
cache: "pnpm"
# I could have only added the turbo-ignore without specifying the sha to the last
# commit of the base branch but that would make the turbo compare with the parent
# commit of the branch. This would make the CI fail when the dev makes
# a change that affects the design-system in the first commit and pass
# when the dev makes a change that DOES NOT affect the design-system in the second
# commit of the PR.
# We prevent this by comparing the base branch with the head branch.
- name: 🌲 Get branch base commit SHA
id: basecommit
run: |
echo "sha=$(git merge-base ${{github.base_ref}} ${{github.head_ref}})" >> $GITHUB_OUTPUT;
- name: ⏩️ Run Turbo Ignore
id: turbo
continue-on-error: true
run: npx turbo-ignore design-system --fallback=${{steps.basecommit.outputs.sha}}
# Continue only if there were changes in the design-system
- name: 📦 Install dependencies
if: steps.turbo.outcome == 'failure'
run: pnpm install --frozen-lockfile
- name: Build Storybook
if: steps.turbo.outcome == 'failure'
run: pnpm build --filter=design-system
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ secrets.TURBO_TEAM }}
- name: Publish to Chromatic
if: steps.turbo.outcome == 'failure'
uses: chromaui/action@v1
env:
NODE_OPTIONS: --max-old-space-size=16384
with:
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
storybookBuildDir: apps/design-system/storybook-static
exitOnceUploaded: true
onlyChanged: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment