-
Notifications
You must be signed in to change notification settings - Fork 14
224 lines (214 loc) · 7.25 KB
/
release-build-all.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
name: Release - Build All
run-name: Release - Build all from ${{ github.ref_name }}(build ${{ github.run_number }})
on:
pull_request:
types: [opened, reopened, synchronize, closed]
branches:
- main
- "release/**"
- "hotfix/**"
workflow_dispatch:
env:
BUILD_NAMESPACE: ${{ vars.BUILD_NAMESPACE }}
jobs:
# Print variables for logging and debugging purposes.
checkEnv:
name: Check Env variables
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true || github.event_name == 'workflow_dispatch'
steps:
- name: Print Env Vars
run: |
echo Git Base Ref: ${{ github.base_ref }}
echo Git Ref Name: ${{ github.ref_name }}
echo Git Head: ${{ github.event.pull_request.head.sha }}
echo Run Number: ${{ github.run_number }}
# Create new tag.
createTag:
name: Create tag
runs-on: ubuntu-latest
needs: checkEnv
steps:
# Define tag name (e.g. v1.0.0-123).
- name: Define tag name
id: defineTagName
uses: actions/github-script@v7
with:
script: return "${{ github.ref_name }}".replace("release/", "").replace("hotfix/", "") + "-" + "${{ github.run_number }}";
result-encoding: string
# Checkout the code to apply the tag.
- name: Checkout the code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
# Create tag.
- name: Tag the branch
run: |
git config user.name github-actions
git config user.email [email protected]
git tag "${{ steps.defineTagName.outputs.result }}"
git push origin "${{ steps.defineTagName.outputs.result }}"
outputs:
newTag: ${{ steps.defineTagName.outputs.result }}
# Build DB migrations.
build-db-migrations:
name: Build db-migrations
runs-on: ubuntu-latest
needs: createTag
env:
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Print env
run: |
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo BRANCH: ${{ needs.createTag.outputs.newTag }}
echo OC CLI Version: $(oc version)
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.createTag.outputs.newTag }}
- name: Log in to OpenShift
run: |
oc login --token=${{ secrets.SA_TOKEN }} --server=${{ vars.OPENSHIFT_CLUSTER_URL }}
- name: Build db-migrations Image
working-directory: "./devops"
run: |
make oc-build-db-migrations
# Build SIMS-API
build-sims-api:
name: Build SIMS-API
runs-on: ubuntu-latest
needs: createTag
env:
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Print env
run: |
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo BRANCH: ${{ needs.createTag.outputs.newTag }}
echo OC CLI Version: $(oc version)
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.createTag.outputs.newTag }}
- name: Log in to OpenShift
run: |
oc login --token=${{ secrets.SA_TOKEN }} --server=${{ vars.OPENSHIFT_CLUSTER_URL }}
- name: Build SIMS-API Image
working-directory: "./devops"
run: |
make oc-build-api
# Build Workers
build-workers:
name: Build Workers
runs-on: ubuntu-latest
needs: createTag
env:
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Print env
run: |
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo BRANCH: ${{ needs.createTag.outputs.newTag }}
echo OC CLI Version: $(oc version)
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.createTag.outputs.newTag }}
- name: Log in to OpenShift
run: |
oc login --token=${{ secrets.SA_TOKEN }} --server=${{ vars.OPENSHIFT_CLUSTER_URL }}
- name: Build Workers Image
working-directory: "./devops"
run: |
make oc-build-workers
# Build Queue Consumers
build-queue-consumers:
name: Build Queue Consumers
runs-on: ubuntu-latest
needs: createTag
env:
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Print env
run: |
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo BRANCH: ${{ needs.createTag.outputs.newTag }}
echo OC CLI Version: $(oc version)
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.createTag.outputs.newTag }}
- name: Log in to OpenShift
run: |
oc login --token=${{ secrets.SA_TOKEN }} --server=${{ vars.OPENSHIFT_CLUSTER_URL }}
- name: Build Queue Consumers Image
working-directory: "./devops"
run: |
make oc-build-queue-consumers
# Build Web/Frontend
build-web-frontend:
name: Build Web/Frontend
runs-on: ubuntu-latest
needs: createTag
env:
BUILD_REF: ${{ needs.createTag.outputs.newTag }}
steps:
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
- name: Print env
run: |
echo BUILD NAMESPACE: $BUILD_NAMESPACE
echo BRANCH: ${{ needs.createTag.outputs.newTag }}
echo OC CLI Version: $(oc version)
- name: Checkout Target Branch
uses: actions/checkout@v4
with:
ref: ${{ needs.createTag.outputs.newTag }}
- name: Log in to OpenShift
run: |
oc login --token=${{ secrets.SA_TOKEN }} --server=${{ vars.OPENSHIFT_CLUSTER_URL }}
- name: Build Web/Frontend Image
working-directory: "./devops"
run: |
make oc-build-web
# Deploy all applications to DEV when there is a pull request on the main branch.
# If DEV is used to deploy a release or hotfix branch the automatic deploy can be stopped using the env variable because there
# is a Potential to main/relase/hotfix branches have differences (for instance the DB) that would not be backward compatible.
deployAlltoDEV:
if: github.event_name == 'pull_request' && vars.ALLOW_AUTOMATIC_MAIN_BRANCH_DEPLOY_TO_DEV == 'true' && github.ref_name == 'main'
name: Deploy All to DEV
needs:
[
createTag,
build-db-migrations,
build-sims-api,
build-workers,
build-queue-consumers,
build-web-frontend,
]
uses: ./.github/workflows/release-deploy-all.yml
with:
environment: DEV
gitRef: ${{ needs.createTag.outputs.newTag }}
deployCamundaDefinitions: true
deployFormioDefinitions: true
secrets: inherit