forked from qld-gov-au/qgds-bootstrap5
-
Notifications
You must be signed in to change notification settings - Fork 0
191 lines (162 loc) · 5.83 KB
/
compile.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
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build and Test
on:
push:
pull_request:
concurrency:
group: compile-${{ github.workflow }}-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
cancel-in-progress: true
jobs:
validate:
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '20']
name: Lint test on Node ${{ matrix.node }}
steps:
- run: echo ${{github.ref}}
- uses: actions/checkout@v4
- 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 on lint step (Which is cached)
run: |
npm -v
node -v
# cat /home/runner/work/_temp/.npmrc #only nice to test when registry is altered
#env:
# NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }}
- name: Install
run: | # Install packages
npm install --prefer-offline --no-audit --ignore-scripts --force
#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: Lint
run: |
npm run lint
- name: Test
run: |
npm run test
build:
needs: validate
runs-on: ubuntu-latest
strategy:
matrix:
node: [ '20' ]
name: Build and Deploy on Node ${{ matrix.node }}
steps:
- uses: actions/[email protected]
- 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: Use Node.js
uses: actions/[email protected]
with:
node-version: ${{ matrix.node }}
cache: 'npm'
#always-auth: 'true'
#registry-url: 'https://nexus.tools.services.qld.gov.au/nexus/repository/npm_all/'
registry-url: 'https://registry.npmjs.org'
- 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: | # build the files
npm run build
# - name: Build storybook 🔧
# run: | # build the Storybook files
# npm run build-storybook
- name: setup Package
run: |
ls -ltr
mkdir -p ./target/docs
cp -r ./docs ./target/docs
cp -r ./dist ./target/dist
- uses: actions/[email protected]
with:
name: Package
path: ./target
- name: Extract branch name
shell: bash
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
id: extract_branch
- name: display branch name
shell: bash
run: echo "${{ steps.extract_branch.outputs.branch }}"
- name: setup Publish
run: |
set -x
cp -r ./binary-repo/* ./dist
- name: Publish qgds-qol-dist
uses: qld-gov-au/gha-publish-to-git@master
with:
repository: ${{ secrets.TARGET_REPO }}
git_ref: '${{ github.ref }}'
branch: '${{ steps.extract_branch.outputs.branch }}'
github_token: '${{ secrets.GH_TOKEN }}'
github_pat: '${{ secrets.GH_PAT }}'
source_folder: dist
tag_branch: main
if: success()
- name: Publish to qgds-qol-cdn
uses: qld-gov-au/gha-cdn-version-tree-by-tag-builder@main
with:
repository: 'qld-gov-au/formio-qld-cdn'
git_ref: '${{ github.ref }}'
branch: 'release'
github_token: '${{ secrets.GH_TOKEN }}'
github_pat: '${{ secrets.GH_PAT }}'
source_folder: dist
if: success()
- name: Build Storybook 🔧
run: | # build the Storybook files
npm run build-storybook
- name: Package storybook files
uses: actions/upload-artifact@v4 #provide nice artifact
with:
name: Storybook
path: storybook-static