-
Notifications
You must be signed in to change notification settings - Fork 3
154 lines (131 loc) Β· 5.21 KB
/
ci.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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: CI
on: push
jobs:
test:
name: Lint & Test
runs-on: ubuntu-latest
env:
TZ: Australia/Brisbane
CI: true
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup environment
id: setups
run: |-
echo "::set-output name=yarn_cache::$(yarn cache dir)"
echo "::set-output name=node_version::$(jq -r '.volta.node' package.json)"
- name: Setup Node ${{ steps.setups.outputs.node_version }}
uses: actions/setup-node@main
with:
node-version: ${{ steps.setups.outputs.node_version }}
check-latest: true
- name: Yarn cache
uses: actions/cache@v3
with:
path: ${{ steps.setups.outputs.yarn_cache }}
key:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock')
}}-node-${{ steps.setups.outputs.node_version }}
- run: yarn --frozen-lockfile
- name: Lint
run: yarn lint
- name: Test
run: yarn test --no-cache --ci --coverage
- uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV }}
visual_test:
name: Visual changes
runs-on: ubuntu-latest
if: |
!contains(github.ref, 'renovate') &&
!contains(github.ref, 'changeset')
env:
TZ: Australia/Brisbane
CI: true
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0
- name: Setup environment
id: setups
run: |-
echo "::set-output name=yarn_cache::$(yarn cache dir)"
echo "::set-output name=node_version::$(jq -r '.volta.node' package.json)"
- name: Setup Node ${{ steps.setups.outputs.node_version }}
uses: actions/setup-node@main
with:
node-version: ${{ steps.setups.outputs.node_version }}
check-latest: true
- name: Yarn cache
uses: actions/cache@v3
with:
path: ${{ steps.setups.outputs.yarn_cache }}
key:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock')
}}-node-${{ steps.setups.outputs.node_version }}
- run: yarn --frozen-lockfile
- name: Chromatic (main)
if: github.ref == 'refs/heads/main'
run: yarn run chromatic test --auto-accept-changes
env:
CHROMATIC_APP_CODE: ${{ secrets.CHROMATIC_APP_CODE }}
- name: Chromatic (prs)
if: |
github.ref != 'refs/heads/main' &&
!contains(github.ref, 'renovate') &&
!contains(github.ref, 'changeset')
run: yarn run chromatic test --exit-once-uploaded
env:
CHROMATIC_APP_CODE: ${{ secrets.CHROMATIC_APP_CODE }}
preview:
name: Preview
runs-on: ubuntu-latest
if: |
!contains(github.ref, 'renovate') &&
!contains(github.ref, 'changeset')
env:
TZ: Australia/Brisbane
CI: true
steps:
- uses: actions/checkout@main
- name: Setup environment
id: setups
run: |-
echo "::set-output name=yarn_cache::$(yarn cache dir)"
echo "::set-output name=node_version::$(jq -r '.volta.node' package.json)"
- name: Setup Node ${{ steps.setups.outputs.node_version }}
uses: actions/setup-node@main
with:
node-version: ${{ steps.setups.outputs.node_version }}
- name: Yarn cache
uses: actions/cache@main
with:
path: ${{ steps.setups.outputs.yarn_cache }}
key:
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock')
}}-node-${{ steps.setups.outputs.node_version }}
- run: yarn --frozen-lockfile
- name: Build Storybook
run: yarn storybook:build
- name: Stage ready for deploy
run: |-
mkdir -p site-dist;
mv storybook-static/* site-dist/;
- name: Deploy Site (main)
if: github.ref == 'refs/heads/main'
run: npx surge -p site-dist/ -d overdrive.autoguru.io
env:
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
- name: Deploy Site (pr)
if: github.ref != 'refs/heads/main'
run: >-
npx surge -p site-dist/ -d overdrive--${GITHUB_SHA}.surge.sh
&& node ./scripts/githubPostPreviewLink.js
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }}
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}