-
Notifications
You must be signed in to change notification settings - Fork 5
207 lines (197 loc) · 6.88 KB
/
cicd-prd.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
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
207
name: "CICD production"
on:
# On merged
push:
branches:
- main
# On released
release:
types: [published]
jobs:
build-docker:
permissions:
id-token: write
contents: write
runs-on: ubuntu-22.04
if: github.actor != 'dependabot[bot]'
name: "Deploy image"
strategy:
fail-fast: false
matrix:
application:
[
bluebell-playground,
devex-apollo,
dev-wallet,
faucet-service,
eth-spout,
governance-api,
governance-snapshot,
multisig,
neo-savant,
scilla-server,
zillion,
]
include:
- application: bluebell-playground
image_name: bluebell-playground
path: products/bluebell
tag_length: 8
tag_latest: false
- application: devex-apollo
image_name: devex-apollo
path: products/devex-apollo
tag_length: 8
tag_latest: false
- application: dev-wallet
image_name: dev-wallet
path: products/dev-wallet
tag_length: 8
tag_latest: false
- application: faucet-service
image_name: faucet-service
path: products/faucet-service
tag_length: 8
tag_latest: false
- application: eth-spout
image_name: eth-spout
path: products/eth-spout
tag_length: 9
tag_latest: true
- application: governance-api
image_name: governance-api
path: products/governance-api
tag_length: 8
tag_latest: false
- application: governance-snapshot
image_name: governance-snapshot
path: products/governance-snapshot
tag_length: 8
tag_latest: false
- application: multisig
image_name: multisig
path: products/multisig
tag_length: 8
tag_latest: false
- application: neo-savant
image_name: neo-savant
path: products/neo-savant
tag_length: 8
tag_latest: false
- application: scilla-server
image_name: scilla-server
path: products/scilla-server
tag_length: 8
tag_latest: false
- application: zillion
image_name: zillion
path: products/zillion
tag_length: 8
tag_latest: false
env:
DOCKER_DOMAIN: asia-docker.pkg.dev
REGISTRY: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-public
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: Docker build and push - production
uses: Zilliqa/gh-actions-workflows/actions/ci-dockerized-app-build-push@v2
with:
context: ${{ matrix.path }}
push: true
tag: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-public/${{ matrix.image_name }}:${{ github.ref_name }}
registry: asia-docker.pkg.dev
workload-identity-provider: "${{ secrets.GCP_PRD_GITHUB_WIF }}"
service-account: "${{ secrets.GCP_PRD_GITHUB_SA_DOCKER_REGISTRY }}"
cache-key: ${{ env.REGISTRY }}/${{ matrix.image_name }}-cache
build-args: |
DEPLOY_ENV=prd
VITE_ENV="PROD"
build-makefile:
permissions:
id-token: write
contents: write
runs-on: ubuntu-22.04
name: "Build image with Makefile"
strategy:
fail-fast: false
matrix:
application: [devex, zilliqa-isolated-server]
include:
- application: devex
image_name: devex
path: products/devex
tag_length: 8
tag_latest: false
- application: zilliqa-isolated-server
image_name: zilliqa-isolated-server
path: products/zilliqa-isolated-server
tag_length: 8
tag_latest: true
env:
DOCKER_DOMAIN: asia-docker.pkg.dev
REGISTRY: asia-docker.pkg.dev/prj-p-devops-services-tvwmrf63/zilliqa-public
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: recursive
ref: ${{ github.event.pull_request.head.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0
- name: "Authenticate to Google Cloud - production"
id: google-auth
uses: "google-github-actions/auth@v1"
with:
token_format: "access_token"
workload_identity_provider: "${{ secrets.GCP_PRD_GITHUB_WIF }}"
service_account: "${{ secrets.GCP_PRD_GITHUB_SA_DOCKER_REGISTRY }}"
create_credentials_file: true
- name: Login to the registry - production
uses: docker/login-action@v2
with:
registry: ${{ env.DOCKER_DOMAIN }}
username: "oauth2accesstoken"
password: "${{ steps.google-auth.outputs.access_token }}"
- name: Get tag version - production
if: github.event_name == 'push'
id: set-tag
uses: Zilliqa/gh-actions-workflows/actions/generate-tag@v1
with:
tag: ${{ env.REGISTRY }}/${{ matrix.image_name }}
length: ${{ matrix.tag_length }}
- name: "Build and push ${{ matrix.application }} - production"
if: github.event_name == 'push'
env:
ENVIRONMENT: prd
IMAGE_TAG: ${{ steps.set-tag.outputs.tags }}
ENV_FILES_DECRYPTER_NONPRD: ${{ secrets.ENV_FILES_DECRYPTER_NONPRD }}
ENV_FILES_DECRYPTER_PRD: ${{ secrets.ENV_FILES_DECRYPTER_PRD }}
run: |
cd ${{ matrix.path }}
make image/build-and-push
- name: "Build and push ${{ matrix.application }} - production"
if: github.event_name == 'release'
env:
ENVIRONMENT: prd
IMAGE_TAG: ${{ env.REGISTRY }}/${{ matrix.image_name }}:${{ github.ref_name }}
ENV_FILES_DECRYPTER_NONPRD: ${{ secrets.ENV_FILES_DECRYPTER_NONPRD }}
ENV_FILES_DECRYPTER_PRD: ${{ secrets.ENV_FILES_DECRYPTER_PRD }}
run: |
cd ${{ matrix.path }}
make image/build-and-push
- name: "Build and push ${{ matrix.application }} tag latest - production"
if: matrix.tag_latest == true && github.event_name == 'release'
env:
ENVIRONMENT: prd
IMAGE_TAG: ${{ env.REGISTRY }}/${{ matrix.image_name }}:latest
ENV_FILES_DECRYPTER_NONPRD: ${{ secrets.ENV_FILES_DECRYPTER_NONPRD }}
ENV_FILES_DECRYPTER_PRD: ${{ secrets.ENV_FILES_DECRYPTER_PRD }}
run: |
cd ${{ matrix.path }}
make image/build-and-push