-
Notifications
You must be signed in to change notification settings - Fork 0
259 lines (224 loc) · 8.28 KB
/
release.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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
name: Default Release Workflow
on:
push:
branches: [develop, main]
pull_request:
branches: [develop, main]
workflow_dispatch:
jobs:
#################################################################################
# Environment: -
# Build & Lint
#################################################################################
BuildArtifacts:
name: Build Artifacts job
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
app: ['krew-ui-angular', 'krew-ui-svelte', 'krew-ui-react', 'krew-website']
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: '0'
persist-credentials: false
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node-version }}
- name: Check cache
uses: actions/cache@v2
id: node-cache
with:
path: '**/node_modules'
key: ubuntu-latest-node-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: Install node modules
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Build app ${{ matrix.app }}
run: npm run build -- ${{ matrix.app }} --configuration=production
- name: Display structure of dist folder
run: ls -R
working-directory: dist
- name: Archive artifacts
uses: actions/upload-artifact@v2
with:
name: artifacts
path: dist/apps
#################################################################################
# Environment: Preview Channels
# Preview URL
#################################################################################
CreatePreview:
name: Deploy Preview URL
if: ${{ github.event_name == 'pull_request' }}
needs: [BuildArtifacts]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
app: ['krew-ui-angular', 'krew-ui-svelte', 'krew-ui-react', 'krew-website']
env:
PREVIEW_ID: ${{ matrix.app }}-PR-${{github.event.number}}
environment:
name: Preview Channels
url: ${{ steps.action-hosting-deploy.outputs.details_url }}
steps:
- uses: actions/checkout@v2
if: |
contains(github.event.pull_request.labels.*.name, format('app: {0}', matrix.app))
- uses: actions/download-artifact@master
if: |
contains(github.event.pull_request.labels.*.name, format('app: {0}', matrix.app))
with:
name: artifacts
path: dist/apps
- name: Display structure of downloaded files
if: |
contains(github.event.pull_request.labels.*.name, format('app: {0}', matrix.app))
run: ls -R
working-directory: dist
- name: Prepare deploy
if: |
contains(github.event.pull_request.labels.*.name, format('app: {0}', matrix.app))
run: |
cp -f apps/${{ matrix.app }}/server/.firebaserc ./
cp -f apps/${{ matrix.app }}/server/firebase.json ./
- uses: FirebaseExtended/action-hosting-deploy@v0
id: action-hosting-deploy
if: |
contains(github.event.pull_request.labels.*.name, format('app: {0}', matrix.app))
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
projectId: m4m-krew-dev
channelId: ${{ env.PREVIEW_ID }}
#################################################################################
# Environment: Test
# Deploy to Firebase
#################################################################################
DeployTest:
name: Deploy to Test
if: github.event.ref == 'refs/heads/develop'
needs: [BuildArtifacts]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
app: ['krew-ui-angular', 'krew-ui-svelte', 'krew-ui-react', 'krew-website']
environment:
name: Test
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@master
with:
name: artifacts
path: dist/apps
- name: Display structure of downloaded files
run: ls -R
working-directory: dist
- name: Prepare deploy
run: |
cp -f apps/${{ matrix.app }}/server/.firebaserc ./
cp -f apps/${{ matrix.app }}/server/firebase.json ./
- name: Deploy ${{ matrix.app }} to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
id: action-hosting-deploy
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
projectId: m4m-krew-dev
channelId: live
#################################################################################
# Environment: Production
# Releasing
#################################################################################
CreateRelease:
name: Release to GitHub Releases
if: "github.event.ref == 'refs/heads/main' && ! contains(toJSON(github.event.commits.*.message), '[skip-ci]')"
needs: [BuildArtifacts]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
environment:
name: Production
steps:
- uses: actions/checkout@v2
with:
fetch-depth: '0'
persist-credentials: false
- name: Use Node ${{ matrix.node-version }}
uses: actions/setup-node@v2-beta
with:
node-version: ${{ matrix.node-version }}
- name: Check cache
uses: actions/cache@v2
id: node-cache
with:
path: '**/node_modules'
key: ubuntu-latest-node-modules-${{ matrix.node-version }}-${{ hashFiles('**/package-lock.json') }}
- name: Install node modules
if: steps.node-cache.outputs.cache-hit != 'true'
run: npm ci
env:
CI: true
- uses: actions/download-artifact@master
with:
name: artifacts
path: dist/apps
- name: Prepare artifacts
run: |
mkdir -p ../../artifacts
zip -r -X ../../artifacts/artifacts.zip .
working-directory: dist/apps
- name: Display structure of downloaded files
run: ls -R
working-directory: artifacts
- name: Semantic release
run: npx semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
#################################################################################
# Environment: Production
# Deploy to Firebase
#################################################################################
DeployProd:
name: Deploy to Producton
if: github.event.ref == 'refs/heads/main'
needs: [CreateRelease]
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18]
app: ['krew-ui-angular', 'krew-ui-svelte', 'krew-ui-react', 'krew-website']
environment:
name: Production
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@master
with:
name: artifacts
path: dist/apps
- name: Prepare deploy
run: |
cp -f apps/${{ matrix.app }}/server/.firebaserc ./
cp -f apps/${{ matrix.app }}/server/firebase.json ./
- uses: microsoft/variable-substitution@v1
with:
files: '.firebaserc'
env:
targets.m4m-krew-dev.hosting.krew-ui-angular.0: '${{ secrets.FIREBASE_HOSTING_TARGET_KREW_UI_ANGULAR }}'
targets.m4m-krew-dev.hosting.krew-ui-react.0: '${{ secrets.FIREBASE_HOSTING_TARGET_KREW_UI_REACT }}'
targets.m4m-krew-dev.hosting.krew-ui-svelte.0: '${{ secrets.FIREBASE_HOSTING_TARGET_KREW_UI_SVELTE }}'
targets.m4m-krew-dev.hosting.krew-ui-vue.0: '${{ secrets.FIREBASE_HOSTING_TARGET_KREW_UI_VUE }}'
targets.m4m-krew-dev.hosting.krew-website.0: '${{ secrets.FIREBASE_HOSTING_TARGET_KREW_WEBSITE }}'
- name: Deploy ${{ matrix.app }} to Firebase
uses: FirebaseExtended/action-hosting-deploy@v0
id: action-hosting-deploy
with:
repoToken: '${{ secrets.GITHUB_TOKEN }}'
firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
projectId: '${{ secrets.FIREBASE_PROJECT_ID }}'
channelId: live