-
Notifications
You must be signed in to change notification settings - Fork 1
154 lines (153 loc) · 4.93 KB
/
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
# Build and Deploy to dev env.
# Trigger with tag dev
# Connected with repo environment 'dev'
name: OpenShift Build and Deploy to api and web
on:
push:
branches:
- main-dev
env:
CLUSTER: https://api.silver.devops.gov.bc.ca:6443
AUTH_TOKEN: ${{ secrets.AUTH_TOKEN_OCP4 }}
BUILD_REF: ${{ github.base_ref }}
ENV_PREFIX: dev
NAMESPACE_DEV: ${{ vars.NAMESPACE_DEV }}
SOAM_CLIENT_ID_DEV: ${{ vars.SOAM_CLIENT_ID_DEV }}
SOAM_CLIENT_SECRET_DEV: ${{ secrets.SOAM_CLIENT_SECRET_DEV }}
PUBLIC_HOST: dev.independentschoolservices.gov.bc.ca
jobs:
# Api build
api-build:
name: OpenShift Build & Deploy
runs-on: ubuntu-latest
concurrency: ci-build-api
timeout-minutes: 20
steps:
- name: Set Date time
run: echo "DATE_TIME=$(date ''+%Y%m%d%H%M%S'')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Check changes on backend code
uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'backend/**'
base: ${{ github.ref}}
- name: Build changes
if: steps.changes.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make build-api
make promote-api
- name: Tag the build (api)
if: steps.changes.outputs.src == 'true'
run: |
git config user.name ${{ github.actor }}
git config user.email "iosas-action@gov.bc.ca"
git tag -a build-api-${{ env.DATE_TIME }} -m "Build-api: The build date time tag"
git push origin build-api-${{ env.DATE_TIME }}
# Web build
web-build:
name: OpenShift Build & Deploy
runs-on: ubuntu-latest
concurrency: ci-build-web
timeout-minutes: 20
environment:
name: dev
env:
CERTIFICATE: ${{ secrets.CERT }}
CA_CERT: ${{ secrets.CA_CERT }}
PRIVATE_KEY: ${{ secrets.PRIV_KEY }}
steps:
- name: Set Date time
run: echo "DATE_TIME=$(date ''+%Y%m%d%H%M%S'')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'frontend/**'
base: ${{ github.ref }}
- name: Build changes
if: steps.changes.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make build-web
make promote-web
- name: Tag the build (web)
if: steps.changes.outputs.src == 'true'
run: |
git config user.name ${{ github.actor }}
git config user.email "iosas-action@gov.bc.ca"
git tag -a build-web-${{ env.DATE_TIME }} -m "Build-web: The build date time tag"
git push origin build-web-${{ env.DATE_TIME }}
app-promote:
name: Prmoting application
runs-on: ubuntu-latest
timeout-minutes: 20
needs:
- api-build
- web-build
environment:
name: dev
env:
CERTIFICATE: ${{ secrets.CERT }}
CA_CERT: ${{ secrets.CA_CERT }}
PRIVATE_KEY: ${{ secrets.PRIV_KEY }}
steps:
- name: Set Date time
run: echo "DATE_TIME=$(date ''+%Y%m%d%H%M%S'')" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v2
- name: Check changes on dir
uses: dorny/paths-filter@v2
id: changes_tools
with:
filters: |
src:
- 'backend/**'
- 'tools/**'
base: ${{ github.ref}}
- name: Deploy changes api
if: steps.changes_tools.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make deploy-api
- name: Check changes on dir
uses: dorny/paths-filter@v2
id: changes_tools_web
with:
filters: |
src:
- 'frontend/**'
- 'tools/**'
base: ${{ github.ref }}
- name: Deploy changes of web
if: steps.changes_tools_web.outputs.src == 'true'
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
make print-status
make promote-web
make deploy-web
- name: Create Route
working-directory: './tools'
run: |
oc login --token="$AUTH_TOKEN" --server="$CLUSTER"
echo Creating route with ${{ env.PUBLIC_HOST }}
oc --namespace=${{ env.NAMESPACE_DEV }} process -f openshift/public-route.yml \
-p NAME=web-ecc-iosas \
-p PUBLIC_HOST=${{ env.PUBLIC_HOST }} \
-p CERTIFICATE="${{ secrets.CERT }}" \
-p CA_CERT="${{ secrets.CA_CERT }}" \
-p PRIVATE_KEY="${{ secrets.PRIV_KEY }}" | oc --namespace=${{ env.NAMESPACE_DEV }} apply -f -