1+ name : Base workflow for build.
2+
3+ on :
4+ workflow_call :
5+ inputs :
6+ branch :
7+ required : true
8+ type : string
9+ appName :
10+ required : true
11+ type : string
12+ artifactName :
13+ type : string
14+ default : ' '
15+
16+ jobs :
17+ install-deps :
18+ runs-on : ubuntu-latest
19+
20+ steps :
21+ - uses : actions/checkout@v2
22+ name : Checkout Base
23+
24+ - name : Cache or restore node_modules
25+ id : cache-nodemodules
26+ uses : actions/cache@v2
27+ env :
28+ cache-name : cache-node-modules
29+ with :
30+ # caching node_modules
31+ path : node_modules
32+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
33+ restore-keys : |
34+ ${{ runner.os }}-build-${{ env.cache-name }}-
35+ ${{ runner.os }}-build-
36+ ${{ runner.os }}-
37+
38+ - name : Install dependencies
39+ if : steps.cache-nodemodules.outputs.cache-hit != 'true'
40+ run : npm ci --legacy-peer-deps
41+
42+ validate :
43+ needs : [install-deps]
44+ runs-on : ubuntu-latest
45+
46+ steps :
47+ - uses : actions/checkout@v2
48+ name : Checkout Base
49+
50+ - name : Use Node.js
51+ uses : actions/setup-node@v3
52+ with :
53+ node-version : 14.18.0
54+
55+ - name : Cache or restore node_modules
56+ id : cache-nodemodules
57+ uses : actions/cache@v2
58+ env :
59+ cache-name : cache-node-modules
60+ with :
61+ # caching node_modules
62+ path : node_modules
63+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
64+ restore-keys : |
65+ ${{ runner.os }}-build-${{ env.cache-name }}-
66+ ${{ runner.os }}-build-
67+ ${{ runner.os }}-
68+
69+ - name : Lint
70+ run : npx nx lint ${{ inputs.appName }} --quiet
71+
72+ - name : Test
73+ run : npx nx test ${{ inputs.appName }} --configuration=single-run
74+
75+ build :
76+ needs : [install-deps]
77+ runs-on : ubuntu-latest
78+
79+ steps :
80+ - uses : actions/checkout@v2
81+ name : Checkout Base
82+
83+ - name : Use Node.js
84+ uses : actions/setup-node@v3
85+ with :
86+ node-version : 14.18.0
87+
88+ - name : Cache or restore node_modules
89+ id : cache-nodemodules
90+ uses : actions/cache@v2
91+ env :
92+ cache-name : cache-node-modules
93+ with :
94+ # caching node_modules
95+ path : node_modules
96+ key : ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
97+ restore-keys : |
98+ ${{ runner.os }}-build-${{ env.cache-name }}-
99+ ${{ runner.os }}-build-
100+ ${{ runner.os }}-
101+
102+ - name : Build
103+ run : npx nx build ${{ inputs.appName }}
104+
105+ - name : Upload app artifacts
106+ if : ${{ inputs.artifactName }}
107+ uses : actions/upload-artifact@master
108+ with :
109+ name : ${{ inputs.artifactName }}
110+ path : dist
0 commit comments