Chromatic #24
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: | |
pull_request: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
# this needs to be a separate job because failures will fail to cache the pnpm store | |
cache: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: checkout for cache | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Cache node_modules | |
id: modules | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Get Date | |
if: ${{ steps.modules.outputs.cache-hit != 'true' }} | |
id: get-date | |
run: | | |
echo "::set-output name=date::$(/bin/date -u "+%Y%m%d")" | |
shell: bash | |
- name: Cache pnpm store | |
if: ${{ steps.modules.outputs.cache-hit != 'true' }} | |
uses: actions/cache@v4 | |
with: | |
path: ~/.pnpm-store | |
# this key is used for all repos, and doesn't update after hit, so only use it for a day | |
key: ${{ runner.os }}-pnpm-${{ matrix.node-version }}-${{ steps.get-date.outputs.date }} | |
- name: pnpm install | |
if: ${{ steps.modules.outputs.cache-hit != 'true' }} | |
uses: pnpm/action-setup@v3 | |
with: | |
run_install: true | |
chromatic-deployment: | |
needs: cache | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v4 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
# here we use the cache we built in the previous job | |
- name: node_modules cache | |
uses: actions/cache@v4 | |
with: | |
path: node_modules | |
key: ${{ runner.os }}-modules-${{ matrix.node-version }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
- name: Install pnpm | |
uses: pnpm/action-setup@v3 | |
with: | |
run_install: false | |
- name: Install dependencies | |
run: | | |
pnpm install | |
pnpm nuxi prepare | |
- name: Publish to Chromatic | |
uses: chromaui/action@latest | |
with: | |
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }} | |
exitOnceUploaded: true | |
#autoAcceptChanges: 'main' |