-
Notifications
You must be signed in to change notification settings - Fork 13
170 lines (122 loc) · 6.48 KB
/
prod-promote.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
# Deploy an artifact onto Prod
name: Promote to Prod
on:
workflow_dispatch:
inputs:
application:
required: true
description: What application you want to promote?
type: choice
options:
- efiling-api
- efiling-frontend
- efiling-admin
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.EFILING_ARTIFACTORY_USERNAME }}
password: ${{ secrets.EFILING_ARTIFACTORY_PASSWORD }}
- name: Backup Prod Image from Artifactory
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker pull artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:prod
docker tag artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:prod artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:prod-backup
docker push artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:prod-backup
- name: Docker Pull Test Image from Artifactory
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker pull artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:test
docker tag artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:test artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:prod
- name: Docker Push Prod Image To Artifactory
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker push artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:prod
# Get SHORT_SHA for the version
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"
- name: Checkout ArgoCD Repo
id: gitops
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-fc726a
ref: main
token: ${{ secrets.ARGO_PAT }}
path: gitops
- name: Update ADMIN Helm Values and Commit
id: helm-admin
if: ${{ github.event.inputs.application == 'efiling-admin' }}
run: |
# Clone the GitOps deployment configuration repository
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
sed -i "s/admintag: .*/admintag: prod # Image Updated on $DATETIME/" ../deploy/prod_values.yaml
sed -i "s/adminVersion: .*/adminVersion: ${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" ../deploy/prod_values.yaml
# Commit and push the changes
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/prod_values.yaml
# Repackage Helm Chart
cd efiling-gitops
helm dependency build
cd charts
git add .
git commit -m "Update Prod Admin image tag"
git push origin main # Update the branch name as needed
- name: Update API Helm Values and Commit
id: helm-api
if: ${{ github.event.inputs.application == 'efiling-api' }}
run: |
# Clone the GitOps deployment configuration repository
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
sed -i "s/apitag: .*/apitag: prod # Image Updated on $DATETIME/" ../deploy/prod_values.yaml
sed -i "s/apiVersion: .*/apiVersion: ${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" ../deploy/prod_values.yaml
# Commit and push the changes
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/prod_values.yaml
# Repackage Helm Chart
cd efiling-gitops
helm dependency build
cd charts
git add .
git commit -m "Update Prod API image tag"
git push origin main # Update the branch name as needed
- name: Update FRONTEND Helm Values and Commit
id: helm-frontend
if: ${{ github.event.inputs.application == 'efiling-frontend' }}
run: |
# Clone the GitOps deployment configuration repository
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
sed -i "s/frontendtag: .*/frontendtag: prod # Image Updated on $DATETIME/" ../deploy/prod_values.yaml
sed -i "s/frontendVersion: .*/frontendVersion: ${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" ../deploy/prod_values.yaml
# Commit and push the changes
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/prod_values.yaml
# Repackage Helm Chart
cd efiling-gitops
helm dependency build
cd charts
git add .
git commit -m "Update Prod FRONTEND image tag"
git push origin main # Update the branch name as needed