-
Notifications
You must be signed in to change notification settings - Fork 11
111 lines (94 loc) · 3.91 KB
/
publish-chromatic.js.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# This workflow is for deploying Storybook to Chromatic [email protected] account, it will consume CHROMATIC_PROJECT_TOKEN in Github secrets.
# Further details on Chromatic setup: https://www.chromatic.com/docs/github-actions
name: Publish Chromatic
on:
push:
branches-ignore:
- 'gh-pages' # 👈 Excludes the gh-pages branch
# - 'master' # 👈 Excludes the master branch
concurrency:
group: compile-${{ github.workflow }}-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
env:
HAVE_CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN != '' }}
strategy:
matrix:
node: [ '18' ]
name: Build and test on Node ${{ matrix.node }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # 👈 Required to retrieve git history
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node }}
cache: 'npm'
always-auth: 'true'
registry-url: 'https://nexus.tools.services.qld.gov.au/nexus/repository/npm_all/'
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }}
name: List the state of node modules
continue-on-error: true
run: npm list
- name: npmrc
run: |
npm -v
node -v
cat /home/runner/work/_temp/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }}
- name: Install #run on lint step (Which is cached)
run: | # Install packages
npm install --prefer-offline --no-audit --ignore-scripts
env:
NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }}
# `npm rebuild` will run all those post-install scripts for us.
- name: rebuild and prepare
run: npm rebuild && npm run prepare --if-present
- name: Build
run: |
npm run build
- name: Test 🔧
run: |
npm run test-ci
- name: Test release 🔧
run: |
npm run test-release
- name: Publish to Chromatic
if: ${{ github.actor != 'dependabot[bot]' && env.HAVE_CHROMATIC_PROJECT_TOKEN == 'true' }}
uses: chromaui/action@latest
# Options required to the GitHub Chromatic Action
with:
# 👇 Chromatic projectToken, refer to the manage page to obtain it.
token: ${{ secrets.GH_TOKEN }}
projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
# 👇 tell Chromatic to rebuild the entire project when a file matching the pattern is changed https://www.chromatic.com/docs/github-actions/#enable-turbosnap
#externals: |
# *.sass
# public/**
onlyChanged: true # 👈 Required option to enable TurboSnap
storybookBuildDir: "storybook-static"
- name: Publish to Chromatic - Is Skipped
if: ${{ env.HAVE_CHROMATIC_PROJECT_TOKEN != 'true' }}
run: |
echo "### Chromatic not configured" >> $GITHUB_STEP_SUMMARY
echo "secrets.CHROMATIC_PROJECT_TOKEN not existing, chromatic did not publish" >> $GITHUB_STEP_SUMMARY
echo "If this is a fork, please setup your own personal chromatic at" >> $GITHUB_STEP_SUMMARY
echo "[chromatic setup](https://www.chromatic.com/setup)" >> $GITHUB_STEP_SUMMARY