forked from bcgov/dts-endorser-service
-
Notifications
You must be signed in to change notification settings - Fork 0
234 lines (211 loc) · 8.49 KB
/
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
name: Build and Deploy Image
on:
workflow_dispatch:
push:
branches:
- main
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
GITHUB_IMAGE_REPO: ghcr.io/rajpalc7/dts-endorser-service
OPENSHIFT_IMAGE_REPO: image-registry.apps.silver.devops.gov.bc.ca/4a9599-tools
APP_NAMES: aries-endorser-agent,aries-endorser-db,aries-endorser-backup,aries-endorser-proxy,aries-endorser-api
TAGS: v1 {{ github.sha}}
jobs:
build:
if: (github.repository == 'rajpalc7/dts-endorser-service') || (github.event_name == 'workflow_dispatch')
name: Build Image
permissions:
packages: write
runs-on: ubuntu-latest
strategy:
matrix:
include:
- service: aries-endorser-agent
GIT_REPO_URL: bcgov/aries-endorser-service
SOURCE_CONTEXT_DIR: docker/acapy
DOCKER_FILE_PATH: Dockerfile.acapy
- service: aries-endorser-db
GIT_REPO_URL: bcgov/aries-endorser-service
PATH: docker/wallet/config
BUILDER_IMAGE: 'registry.redhat.io/rhel9/postgresql-13'
- service: aries-endorser-backup
GIT_REPO_URL: BCDevOps/backup-container
DOCKER_FILE_PATH: Dockerfile
SOURCE_CONTEXT_DIR: docker
# - service: aries-endorser-proxy
# GIT_REPO_URL: BCDevOps/backup-container
# DOCKER_FILE_PATH: Dockerfile
# SOURCE_CONTEXT_DIR: /docker
- service: aries-endorser-api
GIT_REPO_URL: bcgov/aries-endorser-service
DOCKER_FILE_PATH: Dockerfile.endorser
SOURCE_CONTEXT_DIR: endorser
outputs:
image_digest: ${{steps.docker_build.outputs.digest}}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ matrix.GIT_REPO_URL }}
- name: List Directories
run: |
ls -l
echo $service
env:
service: ${{ matrix.service }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to the GHCR
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare docker tags for image
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/rajpalc7/dts-endorser-service/${{ matrix.service }}
flavor: |
latest=true
tags: |
type=schedule
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha,value=latest
if: contains(fromJSON('["aries-endorser-agent","aries-endorser-backup","aries-endorser-api"]'), '$service')
env:
service: ${{ matrix.service }}
# - name: Build and push Docker image
# id: docker_build
# uses: docker/build-push-action@v3
# with:
# context: ${{ matrix.SOURCE_CONTEXT_DIR }}
# file: ${{ matrix.SOURCE_CONTEXT_DIR }}/${{ matrix.DOCKER_FILE_PATH }}
# push: true
# tags: ${{ steps.meta.outputs.tags }}
# labels: ${{ steps.meta.outputs.labels }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
# if: contains(fromJSON(['aries-endorser-agent','aries-endorser-backup','aries-endorser-api']), ${{ matrix.service }} )
- name: Pull base image
id: pull_build_image
run: |
docker pull $builder_image
env:
builder_image: ${{ matrix.BUILDER_IMAGE }}
- name: Setup and Build
id: build_image
uses: redhat-actions/s2i-build@v2
with:
path_context: ${{ matrix.PATH }}
# Builder image for a java project
builder_image: ${{ matrix.BUILDER_IMAGE }}
image: ghcr.io/rajpalc7/dts-endorser-service/${{ matrix.service }}
tags: ${{ env.TAGS }}
# if: contains(["aries-endorser-db"], 'aries-endorser-agent')
- name: Push image
id: push
uses: redhat-actions/push-to-registry@v2
with:
tags: ${{ steps.build_image.outputs.tags }}
image: ${{ steps.build_image.outputs.image }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
if: contains(fromJSON(['aries-endorser-db']), ${{ matrix.service }} )
- name: Print image url
run: |
echo "registry_path=${{ steps.push.outputs.registry-paths }}"
echo "digest=${{ steps.push.outputs.digest }}"
if: contains(fromJson(['aries-endorser-db']), ${{ matrix.service }} )
- name: Display image results
run: |
echo 'imageid=${{ steps.docker_build.outputs.imageid }}'
echo 'digest=${{ steps.docker_build.outputs.digest }}'
if: contains(fromJSON([' aries-endorser-agent','aries-endorser-backup','aries-endorser-api']), ${{ matrix.service }} )
deploy2dev:
needs: build
env:
ENVIRONMENT: dev
permissions:
packages: write
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Deploy to ${{ env.ENVIRONMENT }}
uses: ./.github/workflows/actions/deploy
with:
environment: ${{ env.ENVIRONMENT }}
ghcr_token: ${{ secrets.GITHUB_TOKEN }}
github_image_name: ${{ env.GITHUB_IMAGE_REPO }}/${{ matrix.service }}
image_digest: ${{ needs.build.outputs.image_digest }}
openshift_image_name: ${{ env.OPENSHIFT_IMAGE_REPO }}/${{ matrix.service }}
openshift_server_url: ${{ vars.OPENSHIFT_SERVER_URL }}
namespace: ${{ vars.NAMESPACE }}
deployment_configuration: ${{ matrix.service }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
# docker pull ghcr.io/rajpalc7/dts-endorser-service@sha256:57f946ab1053726ac6fcb71c85a98d355e926904ebe26db4798353668b3f6c68
# docker pull ghcr.io/rajpalc7/dts-endorser-service/aries-endorser-api:sha-e237467
# docker pull ${{ inputs.github_image_name }}@${{ inputs.image_digest }}
# github_image_name: ${{ env.GITHUB_IMAGE_REPO }}${{ matrix.service }}
# GITHUB_IMAGE_REPO: ghcr.io/rajpalc7/dts-endorser-service
# docker pull ghcr.io/rajpalc7/dts-endorser-service
# github_image_name: ghcr.io/rajpalc7/dts-endorser-service
# docker push ghcr.io/rajpalc7/dts-endorser-service/aries-endorser-api
# rocketchat_webhook: ${{ secrets.ROCKETCHAT_WEBHOOK }}
# deploy2test:
# needs: [build, deploy2dev]
# env:
# ENVIRONMENT: test
# permissions:
# packages: write
# runs-on: ubuntu-latest
# environment: test
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: deploy to ${{ env.ENVIRONMENT }}
# uses: ./.github/workflows/actions/deploy
# with:
# environment: ${{ env.ENVIRONMENT }}
# ghcr_token: ${{ secrets.GITHUB_TOKEN }}
# github_image_name: ${{ env.GITHUB_IMAGE_REPO }}${{ env.APP_NAME }}
# image_digest: ${{ needs.build.outputs.image_digest }}
# openshift_image_name: ${{ env.OPENSHIFT_IMAGE_REPO }}${{ env.APP_NAME }}
# openshift_server_url: ${{ vars.OPENSHIFT_SERVER_URL }}
# namespace: ${{ vars.NAMESPACE }}
# deployment_configuration: ${{ env.APP_NAME }}
# openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
# rocketchat_webhook: ${{ secrets.ROCKETCHAT_WEBHOOK }}
# deploy2prod:
# needs: [build, deploy2dev, deploy2test]
# env:
# ENVIRONMENT: prod
# permissions:
# packages: write
# runs-on: ubuntu-latest
# environment: prod
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: deploy to prod
# uses: ./.github/workflows/actions/deploy
# with:
# environment: ${{ env.ENVIRONMENT }}
# ghcr_token: ${{ secrets.GITHUB_TOKEN }}
# github_image_name: ${{ env.GITHUB_IMAGE_REPO }}${{ env.APP_NAME }}
# image_digest: ${{ needs.build.outputs.image_digest }}
# openshift_image_name: ${{ env.OPENSHIFT_IMAGE_REPO }}${{ env.APP_NAME }}
# openshift_server_url: ${{ vars.OPENSHIFT_SERVER_URL }}
# namespace: ${{ vars.NAMESPACE }}
# deployment_configuration: ${{ env.APP_NAME }}
# openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
# rocketchat_webhook: ${{ secrets.ROCKETCHAT_WEBHOOK }}
# aries-endorser-db, aries-endorser-backup, aries-endorser-proxy, aries-endorser-api