-
Notifications
You must be signed in to change notification settings - Fork 51
206 lines (188 loc) · 8.03 KB
/
on_push_main.yaml
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
name: Build, Update Config, and Deploy Development
on:
workflow_dispatch:
push:
branches:
- main
paths:
- "plugins/**"
- "services/tenant-ui/**"
- "charts/traction/**"
- "charts/tenant-ui/**"
jobs:
build_ui:
name: "Build Tenant UI"
runs-on: ubuntu-latest
if: github.repository_owner == 'bcgov'
steps:
- uses: actions/checkout@v4
- name: Build service
uses: ./.github/actions/build_ui
id: builder
with:
context: "./services/tenant-ui"
image_name: ${{ github.repository_owner}}/traction-tenant-ui
registry: ghcr.io
registry_username: ${{ github.repository_owner}}
registry_password: ${{ secrets.GITHUB_TOKEN }}
outputs:
image_tag: ${{ steps.builder.outputs.image_tag }}
image_version: ${{ steps.builder.outputs.image_version }}
build_acapy:
name: "Build Traction Aca-Py"
runs-on: ubuntu-latest
if: github.repository_owner == 'bcgov'
steps:
- uses: actions/checkout@v4
- name: Build Aca-Py Image
uses: ./.github/actions/build_acapy
id: builder
with:
context: "./plugins"
dockerfile: "./plugins/docker/Dockerfile"
image_name: ${{ github.repository_owner}}/traction-plugins-acapy
registry: ghcr.io
registry_username: ${{ github.repository_owner}}
registry_password: ${{ secrets.GITHUB_TOKEN }}
outputs:
image_tag: ${{ steps.builder.outputs.image_tag }}
image_version: ${{ steps.builder.outputs.image_version }}
build_proxy:
name: "Build Traction Tenant Proxy"
runs-on: ubuntu-latest
if: github.repository_owner == 'bcgov'
steps:
- uses: actions/checkout@v4
- name: Build Aca-Py Image
uses: ./.github/actions/build_acapy
id: builder
with:
context: "./plugins"
dockerfile: "./plugins/docker/Dockerfile.tenant-proxy"
image_name: ${{ github.repository_owner}}/traction-tenant-proxy
registry: ghcr.io
registry_username: ${{ github.repository_owner}}
registry_password: ${{ secrets.GITHUB_TOKEN }}
outputs:
image_tag: ${{ steps.builder.outputs.image_tag }}
image_version: ${{ steps.builder.outputs.image_version }}
check_helm_changes:
runs-on: ubuntu-latest
name: Check for Helm Chart changes
outputs:
helm_changed: ${{ steps.list-changed.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for chart changes
id: list-changed
run: |
if git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep -q "^charts/"; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
update_configs_repo:
runs-on: ubuntu-latest
name: Update Configurations Repo
needs:
- build_ui
- build_acapy
- build_proxy
- check_helm_changes
steps:
- uses: actions/checkout@v4
- name: Checkout services directory from the trust-over-ip-configurations repo
uses: actions/checkout@v4
with:
repository: bcgov/trust-over-ip-configurations
ssh-key: ${{ secrets.DITP_CONFIGS_REPO_SECRET }}
sparse-checkout: |
services
path: trust-over-ip-configurations
- name: Lookup Helm Chart and App versions
id: chart_version
run: |
helm repo add traction https://bcgov.github.io/traction
helm repo update
if [[ "${{ needs.check_helm_changes.outputs.helm_changed }}" == "true" ]]; then
echo "APP_VERSION=$(yq e .appVersion charts/traction/Chart.yaml)" >> $GITHUB_OUTPUT
echo "CHART_VERSION=$(yq e .version charts/traction/Chart.yaml)" >> $GITHUB_OUTPUT
else
echo "APP_VERSION=$(helm search repo traction -ojson | jq '.[0].app_version')" >> $GITHUB_OUTPUT
echo "CHART_VERSION=$(helm search repo traction -ojson | jq '.[0].version')" >> $GITHUB_OUTPUT
fi
- name: Update versions
env:
APP_VERSION: ${{ steps.chart_version.outputs.APP_VERSION }}
CHART_VERSION: ${{ steps.chart_version.outputs.CHART_VERSION }}
IMAGE_TAG: ${{ needs.build_acapy.outputs.image_version }}
run: |
cd trust-over-ip-configurations
yq e -i '.appVersion = env(APP_VERSION)' services/traction/charts/dev/Chart.yaml
yq e -i '.version = env(CHART_VERSION)' services/traction/charts/dev/Chart.yaml
yq e -i '.dependencies[0].version = env(CHART_VERSION)' services/traction/charts/dev/Chart.yaml
yq e -i '.traction.acapy.image.tag = env(IMAGE_TAG)' services/traction/charts/dev/values.yaml
yq e -i '.traction.tenant_proxy.image.tag = env(IMAGE_TAG)' services/traction/charts/dev/values.yaml
yq e -i '.traction.ui.image.tag = env(IMAGE_TAG)' services/traction/charts/dev/values.yaml
- name: Commit and Push to trust-over-ip-configurations Repo
run: |
cd trust-over-ip-configurations
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add services/traction/charts/dev/values.yaml services/traction/charts/dev/Chart.yaml
git commit -m "Update chart version and image tags" || echo "No changes to commit"
git push origin main
- uses: convictional/[email protected]
id: workflow-trigger
with:
owner: bcgov
repo: trust-over-ip-configurations
github_token: ${{ secrets.DITP_CONFIGS_REPO_TOKEN }}
workflow_file_name: gitops_sync.yaml
- name: Trigger ArgoCD Sync of bc0192-dev-traction
uses: OpsVerseIO/[email protected]
if: needs.check_helm_changes.outputs.helm_changed != 'true' && steps.workflow-trigger.outputs.conclusion == 'success'
with:
address: gitops-shared.apps.silver.devops.gov.bc.ca
token: ${{ secrets.DITP_GITOPS_ARGO_SECRET}}
action: sync
appName: "bc0192-dev-traction"
deploy_dev:
name: Deploy Dev
environment: development
runs-on: ubuntu-latest
needs:
- build_ui
- build_acapy
- build_proxy
- check_helm_changes
if: ${{ needs.check_helm_changes.outputs.helm_changed == 'true' && contains(needs.*.result, 'success') && !(contains(needs.*.result, 'failure')) && (github.repository_owner == 'bcgov') }}
steps:
- uses: actions/checkout@v4
- name: Checkout services directory from the trust-over-ip-configurations repo
uses: actions/checkout@v4
with:
repository: bcgov/trust-over-ip-configurations
ssh-key: ${{ secrets.DITP_CONFIGS_REPO_SECRET }}
sparse-checkout: |
services
path: trust-over-ip-configurations
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
certificate_authority_data: ${{ secrets.OPENSHIFT_CA_CRT }}
namespace: ${{ secrets.OPENSHIFT_NAMESPACE }}
- name: Deploy Traction to Development
run: |
cp trust-over-ip-configurations/services/traction/charts/dev/values.yaml ./dev-values.yaml
yq e -i 'del(.traction) | . *= load("trust-over-ip-configurations/services/traction/charts/dev/values.yaml").traction' ./dev-values.yaml
helm upgrade --install traction -f ./dev-values.yaml --set acapy.image.tag=${{ needs.build_acapy.outputs.image_version }} --set tenant_proxy.image.tag=${{ needs.build_acapy.outputs.image_version }} --set ui.image.tag=${{ needs.build_ui.outputs.image_version }} ./charts/traction --wait
- name: Restart Deployments
run: |
oc rollout restart deployment/traction-acapy
oc rollout restart deployment/traction-tenant-proxy
oc rollout restart deployment/traction-tenant-ui