-
Notifications
You must be signed in to change notification settings - Fork 2
130 lines (118 loc) · 4.15 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
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
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
# push:
# branches:
# - dev
# - main
# - test
jobs:
build-push:
name: Build and Push to Registry
runs-on: ubuntu-latest
outputs:
api: ${{ steps.filter.outputs.api }}
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@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: filter
uses: dorny/paths-filter@v2
id: filter
with:
filters: |
api:
- 'src/api/**'
- 'src/libs/**'
dashboard:
- 'src/dashboard/**'
db-migration:
- 'src/libs/dal/**'
## BUILD
- name: Build API
id: build-api
uses: redhat-actions/buildah-build@v2
if: steps.filter.outputs.api == 'true'
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 Dasbhoard
id: build-app
uses: redhat-actions/buildah-build@v2
if: steps.filter.outputs.dashboard == 'true'
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/buildah-build@v2
if: steps.filter.outputs.db-migration == 'true'
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'
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 Dashboard to registry
uses: redhat-actions/push-to-registry@v2
if: steps.filter.outputs.dashboard == 'true'
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'
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 }}