-
Notifications
You must be signed in to change notification settings - Fork 2
219 lines (187 loc) · 6.88 KB
/
Copy pathdev.yml
File metadata and controls
219 lines (187 loc) · 6.88 KB
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
name: 1. Build & Deploy to Dev
#Will automatically run on a push to main, but can also be run manually
on:
push:
branches: [ "main" ]
paths-ignore:
- '.github/**'
workflow_dispatch:
env:
ENVIRONMENT: dev
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
jobs:
build-static:
runs-on: ubuntu-latest
name: Build & Push Static Image
environment: dev
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.IMAGE_REGISTRY }}/drivebc-static
tags: |
type=raw,value=latest
type=raw,value=latest-dev
type=sha,format=long
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v7
with:
context: .
file: ./compose/frontend/StaticBuild
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: |
${{ steps.meta.outputs.labels }}
app=drivebc
build-args: |
DEBUG_BUILD=true
secrets: |
"FONTAWESOME_PACKAGE_TOKEN=${{ secrets.FONTAWESOME_PACKAGE_TOKEN }}"
build-backend:
runs-on: ubuntu-latest
name: Build & Push Backend Image
environment: dev
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Build Backend
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: drivebc-django
tags: latest latest-dev ${{ github.sha }}
labels: |
app=drivebc
containerfiles: ./compose/backend/Dockerfile
build-args:
DEBUG_BUILD=true
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
build-redis:
runs-on: ubuntu-latest
name: Build & Push Redis Image
environment: dev
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Build Redis
id: build_image
uses: redhat-actions/buildah-build@v2
with:
image: drivebc-redis
tags: latest latest-dev ${{ github.sha }}
labels: |
app=drivebc
containerfiles: ./compose/redis/Dockerfile
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
build-openshiftjobs:
runs-on: ubuntu-latest
name: Build & Push OpenShift Jobs Image
environment: dev
steps:
- name: Checkout Code
uses: actions/checkout@v6
- name: Build OpenShift Jobs
id: build_image
uses: redhat-actions/buildah-build@v2
with:
context: .
layers: true
image: drivebc-openshiftjobs
tags: latest latest-dev ${{ github.sha }}
labels: |
app=drivebc
containerfiles: ./compose/openshiftjobs/DockerFile
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
update-openshift-gold:
needs: [build-static, build-backend, build-redis, build-openshiftjobs]
runs-on: ubuntu-latest
name: Deploy Latest Images to OpenShift Gold
environment:
name: dev
url: https://dev-drivebc.apps.gold.devops.gov.bc.ca
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
skip_cache: true
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ vars.OPENSHIFT_GOLD_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_GOLD_TOKEN }}
namespace: ${{ vars.OPENSHIFT_NAMESPACE }}
insecure_skip_tls_verify: false
- name: Helm upgrade on OpenShift Gold Environment
run: |
helm upgrade dev-drivebc -f ./infrastructure/main/values-dev.yaml ./infrastructure/main --set static.image.tag=sha-${{ github.sha }} --set django.image.tag=${{ github.sha }} --set tasks.image.tag=${{ github.sha }} --set image-consumer.image.tag=${{ github.sha }} --set redis.image.tag=${{ github.sha }} --set openshiftjobs.image.tag=${{ github.sha }}
# I have this run after the push to Gold because I want to make sure that Gold runs the migrations first. Gold DR can't run migrations as DB is read-only
update-openshift-golddr:
needs: [update-openshift-gold]
runs-on: ubuntu-latest
name: Deploy Latest Images to OpenShift GoldDR
environment:
name: dev
url: https://dev-drivebc.apps.golddr.devops.gov.bc.ca
steps:
- name: Checkout code
uses: actions/checkout@v6
- name: Install CLI tools from OpenShift Mirror
uses: redhat-actions/openshift-tools-installer@v1
with:
oc: "4"
skip_cache: true
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ vars.OPENSHIFT_GOLDDR_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_GOLDDR_TOKEN }}
namespace: ${{ vars.OPENSHIFT_NAMESPACE }}
insecure_skip_tls_verify: false
- name: Helm upgrade on OpenShift GoldDR Environment
run: |
helm upgrade dev-drivebc -f ./infrastructure/main/values-dev.yaml -f ./infrastructure/main/values-dev-dr.yaml ./infrastructure/main --set static.image.tag=sha-${{ github.sha }} --set django.image.tag=${{ github.sha }} --set tasks.image.tag=${{ github.sha }} --set image-consumer.image.tag=${{ github.sha }} --set redis.image.tag=${{ github.sha }} --set openshiftjobs.image.tag=${{ github.sha }}
# automatedTests:
# needs: [versionUpdate]
# name: Automated Smoke Test
# uses: bcgov/DriveBC.ca-automated-tests/.github/workflows/playwright.yml@main
# with:
# environment: 'dev'
# secrets: inherit