Skip to content

Commit 8bd1023

Browse files
authored
CD: build NameX Pay in GCP (#1590)
1 parent 3d943df commit 8bd1023

File tree

4 files changed

+122
-195
lines changed

4 files changed

+122
-195
lines changed

.github/workflows/namex-pay-cd.yml

Lines changed: 18 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -3,111 +3,28 @@ name: Namex Pay CD
33
on:
44
push:
55
branches:
6-
- main
6+
- feature-gcp-build
77
paths:
88
- "services/namex-pay/**"
99
workflow_dispatch:
1010
inputs:
11-
environment:
12-
description: "Environment (dev/test/prod)"
11+
target:
12+
description: "Deploy To"
1313
required: true
14-
default: "dev"
15-
16-
defaults:
17-
run:
18-
shell: bash
19-
working-directory: ./services/namex-pay
20-
21-
env:
22-
APP_NAME: "namex-pay"
23-
TAG_NAME: "dev"
14+
type: choice
15+
options:
16+
- dev
17+
- test
18+
- sandbox
19+
- prod
2420

2521
jobs:
26-
namex-pay-cd-by-push:
27-
runs-on: ubuntu-20.04
28-
29-
if: github.event_name == 'push' && github.repository == 'bcgov/namex'
30-
environment:
31-
name: "dev"
32-
33-
steps:
34-
- uses: actions/checkout@v3
35-
36-
- name: Login Openshift
37-
shell: bash
38-
run: |
39-
oc login --server=${{secrets.OPENSHIFT4_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT4_SA_TOKEN}}
40-
41-
- name: CD Flow
42-
shell: bash
43-
env:
44-
OPS_REPOSITORY: ${{ secrets.OPS_REPOSITORY }}
45-
OPENSHIFT_DOCKER_REGISTRY: ${{ secrets.OPENSHIFT4_DOCKER_REGISTRY }}
46-
OPENSHIFT_SA_NAME: ${{ secrets.OPENSHIFT4_SA_NAME }}
47-
OPENSHIFT_SA_TOKEN: ${{ secrets.OPENSHIFT4_SA_TOKEN }}
48-
OPENSHIFT_REPOSITORY: ${{ secrets.OPENSHIFT4_REPOSITORY }}
49-
TAG_NAME: ${{ env.TAG_NAME }}
50-
run: |
51-
make cd
52-
53-
- name: Watch new rollout (trigger by image change in Openshift)
54-
shell: bash
55-
run: |
56-
oc rollout status dc/${{ env.APP_NAME }}-${{ env.TAG_NAME }} -n ${{ secrets.OPENSHIFT4_REPOSITORY }}-${{ env.TAG_NAME }} -w
57-
58-
- name: Rocket.Chat Notification
59-
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master
60-
if: failure()
61-
with:
62-
type: ${{ job.status }}
63-
job_name: "*Namex Pay Built and Deployed to ${{env.TAG_NAME}}*"
64-
channel: "#registries-bot"
65-
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
66-
commit: true
67-
token: ${{ secrets.GITHUB_TOKEN }}
68-
69-
namex-pay-cd-by-dispatch:
70-
runs-on: ubuntu-20.04
71-
72-
if: github.event_name == 'workflow_dispatch' && github.repository == 'bcgov/namex'
73-
environment:
74-
name: "${{ github.event.inputs.environment }}"
75-
76-
steps:
77-
- uses: actions/checkout@v3
78-
- name: Set env by input
79-
run: |
80-
echo "TAG_NAME=${{ github.event.inputs.environment }}" >> $GITHUB_ENV
81-
82-
- name: Login Openshift
83-
shell: bash
84-
run: |
85-
oc login --server=${{secrets.OPENSHIFT4_LOGIN_REGISTRY}} --token=${{secrets.OPENSHIFT4_SA_TOKEN}}
86-
87-
- name: CD Flow
88-
shell: bash
89-
env:
90-
OPS_REPOSITORY: ${{ secrets.OPS_REPOSITORY }}
91-
OPENSHIFT_DOCKER_REGISTRY: ${{ secrets.OPENSHIFT4_DOCKER_REGISTRY }}
92-
OPENSHIFT_SA_NAME: ${{ secrets.OPENSHIFT4_SA_NAME }}
93-
OPENSHIFT_SA_TOKEN: ${{ secrets.OPENSHIFT4_SA_TOKEN }}
94-
OPENSHIFT_REPOSITORY: ${{ secrets.OPENSHIFT4_REPOSITORY }}
95-
TAG_NAME: ${{ env.TAG_NAME }}
96-
run: |
97-
make cd
98-
99-
- name: Watch new rollout (trigger by image change in Openshift)
100-
shell: bash
101-
run: |
102-
oc rollout status dc/${{ env.APP_NAME }}-${{ env.TAG_NAME }} -n ${{ secrets.OPENSHIFT4_REPOSITORY }}-${{ env.TAG_NAME }} -w
103-
104-
- name: Rocket.Chat Notification
105-
uses: RocketChat/Rocket.Chat.GitHub.Action.Notification@master
106-
if: failure()
107-
with:
108-
type: ${{ job.status }}
109-
job_name: "*Namex Pay Built and Deployed to ${{env.TAG_NAME}}*"
110-
channel: "#registries-bot"
111-
url: ${{ secrets.ROCKETCHAT_WEBHOOK }}
112-
commit: true
113-
token: ${{ secrets.GITHUB_TOKEN }}
22+
namex-pay-cd:
23+
uses: bcgov/bcregistry-sre/.github/workflows/backend-cd.yaml@main
24+
with:
25+
target: ${{ inputs.target }}
26+
app_name: "namex-pay"
27+
working_directory: "./services/namex-pay"
28+
secrets:
29+
WORKLOAD_IDENTIFY_POOLS_PROVIDER: ${{ secrets.WORKLOAD_IDENTIFY_POOLS_PROVIDER }}
30+
GCP_SERVICE_ACCOUNT: ${{ secrets.GCP_SERVICE_ACCOUNT }}

.github/workflows/namex-pay-ci.yml

Lines changed: 9 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -2,106 +2,21 @@ name: Namex Pay CI
22

33
on:
44
pull_request:
5-
types: [assigned, synchronize]
65
paths:
76
- "services/namex-pay/**"
87
workflow_dispatch:
98

109
defaults:
1110
run:
1211
shell: bash
13-
working-directory: ./services/namex-pay
12+
working-directory: "services/namex-pay"
1413

1514
jobs:
16-
setup-job:
17-
runs-on: ubuntu-20.04
18-
19-
steps:
20-
- uses: actions/checkout@v3
21-
- name: setup check
22-
run: |
23-
echo "setup check pass."
24-
25-
linting:
26-
needs: setup-job
27-
runs-on: ubuntu-20.04
28-
29-
strategy:
30-
matrix:
31-
python-version: ["3.12"]
32-
33-
steps:
34-
- uses: actions/checkout@v3
35-
- name: Set up Python ${{ matrix.python-version }}
36-
uses: actions/setup-python@v1
37-
with:
38-
python-version: ${{ matrix.python-version }}
39-
- name: Install dependencies
40-
run: |
41-
make setup
42-
- name: Lint with flake8
43-
id: flake8
44-
run: |
45-
poetry run flake8
46-
47-
testing:
48-
needs: setup-job
49-
env:
50-
DATABASE_TEST_USERNAME: postgres
51-
DATABASE_TEST_PASSWORD: postgres
52-
DATABASE_TEST_NAME: postgres
53-
DATABASE_TEST_HOST: localhost
54-
DATABASE_HOST: localhost
55-
DATABASE_PASSWORD: postgres
56-
57-
TEST_NATS_DOCKER: True
58-
59-
runs-on: ubuntu-20.04
60-
61-
strategy:
62-
matrix:
63-
python-version: ["3.12"]
64-
65-
services:
66-
postgres:
67-
image: postgres:12
68-
env:
69-
POSTGRES_USER: postgres
70-
POSTGRES_PASSWORD: postgres
71-
POSTGRES_DB: postgres
72-
ports:
73-
- 5432:5432
74-
# needed because the postgres container does not provide a healthcheck
75-
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
76-
77-
steps:
78-
- uses: actions/checkout@v3
79-
- name: Set up Python ${{ matrix.python-version }}
80-
uses: actions/setup-python@v1
81-
with:
82-
python-version: ${{ matrix.python-version }}
83-
- name: Install dependencies
84-
run: |
85-
make setup
86-
- name: Test with pytest
87-
id: test
88-
run: |
89-
poetry run pytest
90-
- name: Temporarily save coverage.xml
91-
uses: actions/upload-artifact@v2
92-
with:
93-
name: namex-pay-coverage
94-
flags: namexpayapi
95-
path: ./services/namex-pay/coverage.xml
96-
retention-days: 1
97-
98-
build-check:
99-
needs: setup-job
100-
runs-on: ubuntu-20.04
101-
102-
steps:
103-
- uses: actions/checkout@v3
104-
- name: build to check strictness
105-
id: build
106-
run: |
107-
make build-nc
15+
namex-pay-ci:
16+
uses: bcgov/bcregistry-sre/.github/workflows/backend-ci.yaml@main
17+
with:
18+
app_name: "namex-pay"
19+
working_directory: "services/namex-pay"
20+
codecov_flag: "namexpay"
21+
skip_isort: "true"
22+
skip_black: "true"
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
apiVersion: deploy.cloud.google.com/v1
16+
kind: DeliveryPipeline
17+
metadata:
18+
name: namex-pay-pipeline
19+
description: Deployment pipeline
20+
serialPipeline:
21+
stages:
22+
- targetId: a083gt-dev
23+
profiles: [dev]
24+
strategy:
25+
standard:
26+
verify: false
27+
deployParameters:
28+
- values:
29+
deploy-env: "development"
30+
deploy-project-id: "a083gt-dev"
31+
service-name: "namex-pay-dev"
32+
container-name: "namex-pay-dev"
33+
service-account: "sa-api@a083gt-dev.iam.gserviceaccount.com"
34+
- targetId: a083gt-test
35+
profiles: [test]
36+
strategy:
37+
standard:
38+
verify: false
39+
deployParameters:
40+
- values:
41+
deploy-env: "test"
42+
deploy-project-id: "a083gt-test"
43+
service-name: "namex-pay-test"
44+
container-name: "namex-pay-test"
45+
service-account: "sa-api@a083gt-test.iam.gserviceaccount.com"
46+
- targetId: a083gt-sandbox
47+
profiles: [sandbox]
48+
strategy:
49+
standard:
50+
verify: false
51+
deployParameters:
52+
- values:
53+
deploy-env: "sandbox"
54+
deploy-project-id: "a083gt-integration"
55+
service-name: "namex-pay-sandbox"
56+
container-name: "namex-pay-sandbox"
57+
service-account: "sa-api@a083gt-integration.iam.gserviceaccount.com"
58+
- targetId: a083gt-prod
59+
profiles: [prod]
60+
strategy:
61+
standard:
62+
verify: false
63+
deployParameters:
64+
- values:
65+
deploy-env: "production"
66+
deploy-project-id: "a083gt-prod"
67+
service-name: "namex-pay-prod"
68+
container-name: "namex-pay-prod"
69+
service-account: "sa-api@a083gt-prod.iam.gserviceaccount.com"
70+
max-scale: "10"
71+
container-concurrency: "20"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
SENTRY_ENABLE="op://sentry/$APP_ENV/examination/SENTRY_ENABLE"
2+
SENTRY_DSN="op://sentry/$APP_ENV/examination/SENTRY_DSN"
3+
4+
PAY_API_URL="op://API/$APP_ENV/pay-api/PAY_API_URL"
5+
PAY_API_VERSION="op://API/$APP_ENV/pay-api/PAY_API_VERSION"
6+
7+
NAMEX_DATABASE_USERNAME="op://database/$APP_ENV/namex-db/NAMEX_DATABASE_USERNAME"
8+
NAMEX_DATABASE_PASSWORD="op://database/$APP_ENV/namex-db/NAMEX_DATABASE_PASSWORD"
9+
NAMEX_DATABASE_NAME="op://database/$APP_ENV/namex-db/NAMEX_DATABASE_NAME"
10+
NAMEX_DATABASE_HOST="op://database/$APP_ENV/namex-db/NAMEX_DATABASE_HOST"
11+
NAMEX_DATABASE_PORT="op://database/$APP_ENV/namex-db/NAMEX_DATABASE_PORT"
12+
ORACLE_HOST="op://database/$APP_ENV/oracle-base/ORACLE_HOST"
13+
ORACLE_PORT="op://database/$APP_ENV/oracle-base/ORACLE_PORT"
14+
NRO_USER="op://database/$APP_ENV/oracle-namex-db/NRO_USER"
15+
NRO_PASSWORD="op://database/$APP_ENV/oracle-namex-db/NRO_PASSWORD"
16+
NRO_DB_NAME="op://database/$APP_ENV/oracle-namex-db/NRO_DB_NAME"
17+
18+
AUDIENCE="op://gcp-queue/$APP_ENV/base/AUDIENCE"
19+
PUBLISHER_AUDIENCE="op://gcp-queue/$APP_ENV/base/PUBLISHER_AUDIENCE"
20+
NAMEX_MAILER_TOPIC="op://gcp-queue/$APP_ENV/topics/NAMEX_MAILER_TOPIC"
21+
NAMEX_NR_STATE_TOPIC="op://gcp-queue/$APP_ENV/topics/NAMEX_NR_STATE_TOPIC"
22+
BUSINESS_GCP_AUTH_KEY="op://gcp-queue/$APP_ENV/a083gt/BUSINESS_GCP_AUTH_KEY"
23+
PAY_SUB_AUDIENCE="op://gcp-queue/$APP_ENV/namex/PAY_SUB_AUDIENCE"
24+
AUTHPAY_SERVICE_ACCOUNT="op://gcp-queue/$APP_ENV/gtksf3/AUTHPAY_SERVICE_ACCOUNT"

0 commit comments

Comments
 (0)