-
Notifications
You must be signed in to change notification settings - Fork 1
302 lines (301 loc) · 9.38 KB
/
mm.yaml
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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
name: Ministry Mapper
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_DB_URL: ${{ secrets.VITE_FIREBASE_DB_URL }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_BUCKET: ${{ secrets.VITE_FIREBASE_BUCKET }}
VITE_FIREBASE_SENDER_ID: ${{ secrets.VITE_FIREBASE_SENDER_ID }}
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }}
SLACK_BOT_TOKEN: ${{ secrets.SLACK_API_TOKEN}}
on:
pull_request:
branches:
- staging
- master
push:
branches:
- staging
- master
jobs:
verify:
name: Verify Pull Request
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Notify pull request
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
payload: |
{
"blocks" : [{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Initiating pull request verification*"
}
},{
"type": "divider"
}],
"attachments": [
{
"color": "good",
"fields": [
{
"title": "${{ github.event.pull_request.title }}",
"value": "https://github.com/rimorin/ministry-mapper/pull/${{ github.event.number }}"
}
]
}
]
}
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Cache node modules
id: cache-npm
uses: actions/cache@v3
env:
cache-name: cache-node-modules
with:
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
if: steps.cache-npm.outputs.cache-hit != 'true'
# 👆 check if cache-hit happened then do not execute npm ci
run: npm ci
- name: Check code formatting
run: npm run prettier
- name: passed formatting check
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
update-ts: ${{ steps.slack.outputs.ts }}
payload: |
{
"attachments": [
{
"color": "good",
"fields": [
{
"title": "Code formatting",
"value": "Passed"
}
]
}
]
}
- name: Run application test cases
run: npm run test
- name: passed app test
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
update-ts: ${{ steps.slack.outputs.ts }}
payload: |
{
"attachments": [
{
"color": "good",
"fields": [
{
"title": "Application tests",
"value": "Passed"
}
]
}
]
}
- name: Run application build
run: npm run build
- name: passed app build
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
update-ts: ${{ steps.slack.outputs.ts }}
payload: |
{
"attachments": [
{
"color": "good",
"fields": [
{
"title": "Build test",
"value": "Passed"
}
]
}
]
}
- name: Notify passed verification
if: success()
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
update-ts: ${{ steps.slack.outputs.ts }}
payload: |
{
"attachments": [
{
"color": "good",
"fields": [
{
"title": "*Passed Verification*",
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
- name: Notify failed verification
if: failure()
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
update-ts: ${{ steps.slack.outputs.ts }}
payload: |
{
"attachments": [
{
"color": "danger",
"fields": [
{
"title": "*Failed Verification*",
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
# publish_chromatic:
# name: Publish to chromatic
# if: github.event_name == 'pull_request' && github.base_ref == 'master'
# needs: verify
# runs-on: ubuntu-latest
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
# - uses: actions/setup-node@v3
# with:
# node-version: 20
# - name: Install dependencies
# run: npm ci
# - name: Publish to Chromatic
# uses: chromaui/action@v1
# with:
# projectToken: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
# exitZeroOnChanges: true
staging_deployment:
name: Deploy to Staging
if: contains(github.event_name, 'push') && contains(github.ref, 'refs/heads/staging')
runs-on: ubuntu-latest
steps:
- name: Deploy on staging
id: cloudflareRequest
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.STAGING_DEPLOY_HOOK }}
method: "POST"
- name: Failed staging deployment notification
if: failure()
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
payload: |
{
"attachments": [
{
"color": "danger",
"fields": [
{
"title": "*Failed to trigger staging cloudflare deployment job*",
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
- name: Success staging deployment notification
if: success()
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
payload: |
{
"attachments": [
{
"color": "good",
"fields": [
{
"title": "*Triggered staging cloudflare deployment job*"
}
]
}
]
}
production_deployment:
name: Deploy to Production
if: contains(github.event_name, 'push') && contains(github.ref, 'refs/heads/master')
runs-on: ubuntu-latest
env:
HUSKY: 0
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Semantic release
env:
GITHUB_TOKEN: ${{ secrets.GH_ACCESS_TOKEN }}
run: npx semantic-release
- name: Deploy on production
id: cloudflareRequest
uses: fjogeleit/http-request-action@v1
with:
url: ${{ secrets.PRODUCTION_DEPLOY_HOOK }}
method: "POST"
- name: Failed deployment notification
if: failure()
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
payload: |
{
"attachments": [
{
"color": "danger",
"fields": [
{
"title": "*Failed to trigger production cloudflare deployment job*",
"value": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
- name: Success deployment notification
if: success()
uses: slackapi/slack-github-action@v1.23.0
with:
channel-id: ${{ secrets.SLACK_API_CHANNEL_ID }}
payload: |
{
"attachments": [
{
"color": "good",
"fields": [
{
"title": "*Triggered production cloudflare deployment job*"
}
]
}
]
}