-
Notifications
You must be signed in to change notification settings - Fork 18
209 lines (179 loc) · 6.39 KB
/
deploy-apps.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
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: deploy-apps
on:
workflow_dispatch:
inputs:
api:
type: boolean
description: 'Deploy the API application'
default: false
client:
type: boolean
description: 'Deploy the client application'
default: false
elements:
type: boolean
description: 'Deploy the elements application'
default: false
documentation:
type: boolean
description: 'Deploy the documentation application'
default: false
workflow_call:
inputs:
api:
type: boolean
required: true
default: false
client:
type: boolean
required: true
default: false
elements:
type: boolean
required: true
default: false
documentation:
type: boolean
required: true
default: false
secrets:
FIREBASE_DEPLOY_TOKEN:
required: true
defaults:
run:
shell: bash
concurrency:
group: ${{ github.ref_name }}.${{ github.sha }}.deploy-apps
cancel-in-progress: true
jobs:
checks:
runs-on: ubuntu-latest
outputs:
api: ${{ steps.dist-exists.outputs.api }}
client: ${{ steps.dist-exists.outputs.client }}
elements: ${{ steps.dist-exists.outputs.elements }}
documentation: ${{ steps.dist-exists.outputs.documentation }}
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Download dist artifact
uses: ./.github/actions/dist-artifact-download
- name: Check dists existence
id: dist-exists
shell: bash
run: |
echo "--"
echo "-- Check api dist --"
echo "--"
API_DIST_DIR=./dist/apps/api
API_DIST_EXISTS=false
[ -d "$API_DIST_DIR" ] && API_DIST_EXISTS=true
echo "api=$API_DIST_EXISTS" >> $GITHUB_OUTPUT
echo "--"
echo "-- Check client dist --"
echo "--"
CLIENT_DIST_DIR=./dist/apps/client
CLIENT_DIST_EXISTS=false
[ -d "$CLIENT_DIST_DIR" ] && CLIENT_DIST_EXISTS=true
echo "client=$CLIENT_DIST_EXISTS" >> $GITHUB_OUTPUT
echo "--"
echo "-- Check elements dist --"
echo "--"
ELEMENTS_DIST_DIR=./dist/apps/api
ELEMENTS_DIST_EXISTS=false
[ -d "$ELEMENTS_DIST_DIR" ] && ELEMENTS_DIST_EXISTS=true
echo "elements=$ELEMENTS_DIST_EXISTS" >> $GITHUB_OUTPUT
echo "--"
echo "-- Check documentation dist --"
echo "--"
DOCUMENTATION_DIST_DIR=./dist/apps/api
DOCUMENTATION_DIST_EXISTS=false
[ -d "$DOCUMENTATION_DIST_DIR" ] && DOCUMENTATION_DIST_EXISTS=true
echo "documentation=$DOCUMENTATION_DIST_EXISTS" >> $GITHUB_OUTPUT
- name: Print changes
shell: bash
run: |
echo "### :rocket: Existing dists" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- API: $API" >> $GITHUB_STEP_SUMMARY
echo "- CLIENT: $CLIENT" >> $GITHUB_STEP_SUMMARY
echo "- ELEMENTS: $ELEMENTS" >> $GITHUB_STEP_SUMMARY
echo "- DOCUMENTATION: $DOCUMENTATION" >> $GITHUB_STEP_SUMMARY
env:
API: ${{ steps.dist-exists.outputs.api }}
CLIENT: ${{ steps.dist-exists.outputs.client }}
ELEMENTS: ${{ steps.dist-exists.outputs.elements }}
DOCUMENTATION: ${{ steps.dist-exists.outputs.documentation }}
deploy-api:
needs: checks
if: ${{ (inputs.api == true || inputs.api == 'true') && needs.checks.outputs.api == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup environment
uses: ./.github/actions/setup-environment
with:
firebase-tools: true
- name: Download dist artifact
uses: ./.github/actions/dist-artifact-download
# This job works only with a paid plan such as Blaze (https://firebase.google.com/pricing/)
# - name: Deploy api
# if: ${{ (fromJSON(needs.checks.outputs.changes).dependencies == 'true' || fromJSON(needs.checks.outputs.changes).src == 'true') && needs.checks.outputs.origin == 'true' }}
# run: |
# npx nx build api --configuration firebase
# yarn firebase:deploy:ci:api || exit 1
# env:
# FIREBASE_DEPLOY_TOKEN: ${{ secrets.FIREBASE_DEPLOY_TOKEN }}
deploy-client:
needs: checks
if: ${{ (inputs.client == true || inputs.client == 'true') && needs.checks.outputs.client == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup environment
uses: ./.github/actions/setup-environment
with:
firebase-tools: true
- name: Download dist artifact
uses: ./.github/actions/dist-artifact-download
- name: Deploy client
run: yarn firebase:deploy:ci:client || exit 1
env:
FIREBASE_DEPLOY_TOKEN: ${{ secrets.FIREBASE_DEPLOY_TOKEN }}
deploy-elements:
needs: checks
if: ${{ (inputs.elements == true || inputs.elements == 'true') && needs.checks.outputs.elements == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup environment
uses: ./.github/actions/setup-environment
with:
firebase-tools: true
- name: Download dist artifact
uses: ./.github/actions/dist-artifact-download
- name: Deploy elements
run: yarn firebase:deploy:ci:elements || exit 1
env:
FIREBASE_DEPLOY_TOKEN: ${{ secrets.FIREBASE_DEPLOY_TOKEN }}
deploy-documentation:
needs: checks
if: ${{ (inputs.documentation == true || inputs.documentation == 'true') && needs.checks.outputs.documentation == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Setup environment
uses: ./.github/actions/setup-environment
with:
firebase-tools: true
- name: Download dist artifact
uses: ./.github/actions/dist-artifact-download
- name: Deploy documentation
run: yarn firebase:deploy:ci:documentation || exit 1
env:
FIREBASE_DEPLOY_TOKEN: ${{ secrets.FIREBASE_DEPLOY_TOKEN }}