updated CI (#159) #208
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: On Push to Master | |
on: | |
push: | |
branches: | |
- "master" | |
jobs: | |
unit: | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip')" | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/[email protected] | |
with: | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Run Unit Tests | |
run: pnpm test | |
changesets_version: | |
needs: [unit] | |
runs-on: ubuntu-latest | |
if: "!contains(github.event.head_commit.message, 'ci skip')" | |
outputs: | |
published: ${{ steps.published.outputs.published }} | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
token: ${{ secrets.DEPLOY_TOKEN }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/[email protected] | |
with: | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Build | |
run: pnpm build | |
- name: Release | |
id: release | |
uses: changesets/action@v1 | |
with: | |
publish: pnpm run publish | |
version: pnpm run version | |
env: | |
GITHUB_TOKEN: ${{ secrets.DEPLOY_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | |
- name: Update output | |
id: published | |
if: steps.release.outputs.published == 'true' | |
run: echo "published=true" >> "$GITHUB_OUTPUT" | |
deploy_storybook: | |
needs: changesets_version | |
if: needs.changesets_version.outputs.published == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/[email protected] | |
with: | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Deploy | |
run: pnpm storybook:deploy | |
env: | |
GH_TOKEN: ${{ github.actor }}:${{ secrets.GITHUB_TOKEN }} | |
update_chromatic_baseline: | |
needs: changesets_version | |
if: needs.changesets_version.outputs.published == 'true' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
token: ${{ secrets.DEPLOY_TOKEN }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
- uses: pnpm/[email protected] | |
with: | |
run_install: false | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
run: | | |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)" | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: pnpm Install | |
run: pnpm install | |
- name: Chromatic | |
run: | | |
cd packages/react | |
npx chromatic --project-token ${{ secrets.CHROMATIC_PROJECT_TOKEN }} --exit-zero-on-changes --auto-accept-changes --only-changed |