-
Notifications
You must be signed in to change notification settings - Fork 2
158 lines (144 loc) · 5.8 KB
/
ci-cd-dev.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
name: CD/CD Pipeline to DEV
env:
# Artifactory - can't get this to work yet
# DOCKER_ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca/docker-remote
# ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca
# IMAGE_REGISTRY: ${{ secrets.IMAGE_REGISTRY }}
# IMAGE_REGISTRY_USER: ${{ secrets.IMAGE_REGISTRY_USER }}
# IMAGE_REGISTRY_PASSWORD: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_REGISTRY_USER: ${{ github.actor }}
IMAGE_REGISTRY_PASSWORD: ${{ github.token }}
API_IMAGE_NAME: api
DATA_SERVICE_IMAGE_NAME: data-service
APP_IMAGE_NAME: dashboard
DB_MIGRATION_IMAGE_NAME: db-migration
IMAGE_TAG: latest
DEPLOY_TO: dev
VERSION: 1.0.0
on:
pull_request_target:
branches:
- dev
- main
types:
- closed
- opened
- reopened
- edited
push:
branches:
- dev
- main
jobs:
build-push:
name: Build and Push to Registry
runs-on: ubuntu-latest
outputs:
api: ${{ steps.filter.outputs.api }}
data-service: ${{ steps.filter.outputs.data-service }}
dashboard: ${{ steps.filter.outputs.dashboard }}
db-migration: ${{ steps.filter.outputs.db-migration }}
timeout-minutes: 10
permissions:
contents: read
packages: write
steps:
- name: Checkout Source Code
uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: filter
uses: dorny/paths-filter@v3
id: filter
with:
filters: |
api:
- 'src/api/**'
- 'src/libs/**'
data-service:
- 'src/data-service/**'
- 'src/libs/**'
dashboard:
- 'src/dashboard/**'
db-migration:
- 'src/libs/dal/**'
## BUILD
- name: Build API
id: build-api
uses: redhat-actions/[email protected]
if: ${{ steps.filter.outputs.api == 'true' || contains(github.event.pull_request.labels.*.name, 'api') }}
with:
image: ${{ github.event.repository.name }}/${{ env.API_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }}
context: .
dockerfiles: |
src/api/Dockerfile
- name: Build Data Service
id: build-data-service
uses: redhat-actions/[email protected]
if: ${{ steps.filter.outputs.data-service == 'true' || contains(github.event.pull_request.labels.*.name, 'data-service') }}
with:
image: ${{ github.event.repository.name }}/${{ env.DATA_SERVICE_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }}
context: .
dockerfiles: |
src/data-service/Dockerfile
- name: Build Dasbhoard
id: build-app
uses: redhat-actions/[email protected]
if: ${{ steps.filter.outputs.dashboard == 'true' || contains(github.event.pull_request.labels.*.name, 'dashboard') }}
with:
image: ${{ github.event.repository.name }}/${{ env.APP_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }}
context: src/dashboard
dockerfiles: |
src/dashboard/Dockerfile.prod
- name: Build DB Migration
id: build-db-migration
uses: redhat-actions/[email protected]
if: ${{ steps.filter.outputs.db-migration == 'true' || contains(github.event.pull_request.labels.*.name, 'db-migration') }}
with:
image: ${{ github.event.repository.name }}/${{ env.DB_MIGRATION_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }} ${{ env.VERSION }} ${{ env.DEPLOY_TO }}
context: src/libs
dockerfiles: |
src/libs/Dockerfile
## PUSH TO REGISTRY
- name: Push API to registry
uses: redhat-actions/push-to-registry@v2
if: ${{ steps.filter.outputs.api == 'true' || contains(github.event.pull_request.labels.*.name, 'api') }}
with:
image: ${{ steps.build-api.outputs.image }}
tags: ${{ steps.build-api.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_REGISTRY_USER }}
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
- name: Push Data Service to registry
uses: redhat-actions/push-to-registry@v2
if: ${{ steps.filter.outputs.data-service == 'true' || contains(github.event.pull_request.labels.*.name, 'data-service') }}
with:
image: ${{ steps.build-data-service.outputs.image }}
tags: ${{ steps.build-data-service.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_REGISTRY_USER }}
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
- name: Push Dashboard to registry
uses: redhat-actions/push-to-registry@v2
if: ${{ steps.filter.outputs.dashboard == 'true' || contains(github.event.pull_request.labels.*.name, 'dashboard') }}
with:
image: ${{ steps.build-app.outputs.image }}
tags: ${{ steps.build-app.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_REGISTRY_USER }}
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
- name: Push DB Migration to registry
uses: redhat-actions/push-to-registry@v2
if: ${{ steps.filter.outputs.db-migration == 'true' || contains(github.event.pull_request.labels.*.name, 'db-migration') }}
with:
image: ${{ steps.build-db-migration.outputs.image }}
tags: ${{ steps.build-db-migration.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_REGISTRY_USER }}
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}