Skip to content

Commit 019d34a

Browse files
authored
Merge pull request #51 from jujaga/feature/ga-helm-pipeline
CI/CD: Implement Github Actions Helm Chart deployment flow
2 parents e50e048 + 05cae32 commit 019d34a

File tree

14 files changed

+461
-72
lines changed

14 files changed

+461
-72
lines changed

.dockerignore

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Editor directories and files
2+
.DS_Store
3+
.gradle
4+
.nyc_output
5+
.scannerwork
6+
build
7+
coverage
8+
dist
9+
files
10+
**/e2e/videos
11+
node_modules
12+
# Ignore only top-level package-lock.json
13+
/package-lock.json
14+
15+
# Ignore Helm subcharts
16+
charts/**/charts
17+
Chart.lock
18+
19+
# local env files
20+
local.*
21+
local-*.*
22+
.env.local
23+
.env.*.local
24+
25+
# Log files
26+
npm-debug.log*
27+
yarn-debug.log*
28+
yarn-error.log*
29+
30+
# Editor directories and files
31+
.idea
32+
.vscode
33+
*.iml
34+
*.suo
35+
*.ntvs*
36+
*.njsproj
37+
*.sln
38+
*.sw?
39+
*.mp4
40+
41+
# temp office files
42+
~$*
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: Build & Push Container
2+
description: Builds a container from a Dockerfile and pushes to registry
3+
4+
inputs:
5+
context:
6+
description: Effective Working Directory
7+
required: true
8+
default: "./"
9+
image_name:
10+
description: Image Name
11+
required: true
12+
registry:
13+
description: Container Registry
14+
required: true
15+
default: ghcr.io
16+
username:
17+
description: Container Registry Username
18+
required: true
19+
token:
20+
description: Container Registry Authorization Token
21+
required: true
22+
23+
runs:
24+
using: composite
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v2
28+
29+
- name: Login to Container Registry
30+
uses: docker/login-action@v1
31+
with:
32+
registry: ${{ inputs.registry }}
33+
username: ${{ inputs.username }}
34+
password: ${{ inputs.token }}
35+
36+
- name: Prepare Container Metadata tags
37+
id: meta
38+
uses: docker/metadata-action@v3
39+
with:
40+
images: ${{ inputs.registry }}/${{ inputs.username }}/${{ inputs.image_name }}
41+
# Always updates the 'latest' tag
42+
flavor: |
43+
latest=true
44+
# Creates tags based off of branch names and semver tags
45+
tags: |
46+
type=ref,event=branch
47+
type=ref,event=pr
48+
type=semver,pattern={{version}}
49+
type=semver,pattern={{major}}.{{minor}}
50+
type=semver,pattern={{major}}
51+
type=sha
52+
53+
- name: Build and Push to Container Registry
54+
id: builder
55+
uses: docker/build-push-action@v2
56+
with:
57+
context: ${{ inputs.context }}
58+
push: true
59+
tags: ${{ steps.meta.outputs.tags }}
60+
labels: ${{ steps.meta.outputs.labels }}
61+
62+
- name: Inspect Docker Image
63+
shell: bash
64+
run: docker image inspect ${{ inputs.registry }}/${{ inputs.username }}/${{ inputs.image_name }}:latest
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Deploy to Environment
2+
description: Deploys an image to the defined environment
3+
inputs:
4+
app_name:
5+
description: Application general Name
6+
required: true
7+
acronym:
8+
description: Application acronym
9+
required: true
10+
job_name:
11+
description: Job/Instance name
12+
required: true
13+
namespace_prefix:
14+
description: Openshift Namespace common prefix
15+
required: true
16+
namespace_environment:
17+
description: Openshift Namespace environment suffix
18+
required: true
19+
openshift_server:
20+
description: Openshift API Endpoint
21+
required: true
22+
openshift_token:
23+
description: Openshift Service Account Token
24+
required: true
25+
26+
runs:
27+
using: composite
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v2
31+
32+
- name: Login to OpenShift Cluster
33+
uses: redhat-actions/oc-login@v1
34+
with:
35+
openshift_server_url: ${{ inputs.openshift_server }}
36+
openshift_token: ${{ inputs.openshift_token }}
37+
insecure_skip_tls_verify: true
38+
namespace: ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}
39+
40+
- name: Helm Deploy
41+
shell: bash
42+
run: >-
43+
helm upgrade --install --atomic ${{ inputs.job_name }} ${{ inputs.app_name }}
44+
--namespace ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}
45+
--repo https://bcgov.github.io/common-object-management-service
46+
--values ./.github/environments/values.${{ inputs.namespace_environment }}.yaml
47+
--set image.repository=ghcr.io/${{ github.repository_owner }}
48+
--set image.tag=sha-$(git rev-parse --short HEAD)
49+
--set route.host=${{ inputs.acronym }}-${{ inputs.namespace_environment }}-${{ inputs.job_name }}.apps.silver.devops.gov.bc.ca
50+
--set config.configMap.OBJECTSTORAGE_KEY=${{ inputs.acronym }}/${{ inputs.namespace_environment }}
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
name: Push to Registry
2+
description: Copies a container image to a different registry
3+
inputs:
4+
image_name:
5+
description: Image Name
6+
required: true
7+
source_registry:
8+
description: Source Container Registry
9+
required: true
10+
default: ghcr.io
11+
source_username:
12+
description: Source Container Registry Username
13+
required: true
14+
source_token:
15+
description: Source Container Registry Authorization Token
16+
required: true
17+
dest_registry:
18+
description: Destination Container Registry
19+
required: true
20+
dest_username:
21+
description: Destination Container Registry Username
22+
required: true
23+
dest_token:
24+
description: Destination Container Registry Authorization Token
25+
required: true
26+
27+
runs:
28+
using: composite
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v2
32+
33+
- name: Login to Source Container Registry
34+
if: inputs.source_username != ''
35+
uses: docker/login-action@v1
36+
with:
37+
registry: ${{ inputs.source_registry }}
38+
username: ${{ inputs.source_username }}
39+
password: ${{ inputs.source_token }}
40+
41+
- name: Login to Destination Container Registry
42+
if: inputs.dest_username != ''
43+
uses: docker/login-action@v1
44+
with:
45+
registry: ${{ inputs.dest_registry }}
46+
username: ${{ inputs.dest_username }}
47+
password: ${{ inputs.dest_token }}
48+
49+
- name: Copy to Destination Container Registry
50+
if: success()
51+
uses: akhilerm/tag-push-action@v2.0.0
52+
with:
53+
src: ${{ inputs.source_registry }}/${{ inputs.source_username }}/${{ inputs.image_name }}:latest
54+
dst: ${{ inputs.dest_registry }}/${{ inputs.dest_username }}/${{ inputs.image_name }}:latest
55+
56+
- name: Prepare Container Metadata tags
57+
id: meta
58+
uses: docker/metadata-action@v3
59+
with:
60+
images: ${{ inputs.dest_registry }}/${{ inputs.dest_username }}/${{ inputs.image_name }}
61+
# Creates tags based off of branch names and semver tags
62+
tags: |
63+
type=semver,pattern={{version}}
64+
type=semver,pattern={{major}}.{{minor}}
65+
type=semver,pattern={{major}}
66+
type=sha
67+
68+
- name: Add Tags to Destination Container Registry
69+
uses: akhilerm/tag-push-action@v2.0.0
70+
with:
71+
src: ${{ inputs.dest_registry }}/${{ inputs.dest_username }}/${{ inputs.image_name }}:latest
72+
dst: |
73+
${{ steps.meta.outputs.tags }}
74+
75+
- name: Inspect Docker Image
76+
shell: bash
77+
run: |
78+
docker pull ${{ inputs.dest_registry }}/${{ inputs.dest_username }}/${{ inputs.image_name }}:latest
79+
docker image inspect ${{ inputs.dest_registry }}/${{ inputs.dest_username }}/${{ inputs.image_name }}:latest

.github/environments/values.dev.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
features:
3+
basicAuth: true
4+
oidcAuth: true
5+
6+
config:
7+
enabled: true
8+
configMap:
9+
BASICAUTH_ENABLED: "true"
10+
DB_ENABLED: "true"
11+
DB_PORT: "5432"
12+
KC_ENABLED: "true"
13+
KC_IDENTITYKEY: idir_user_guid
14+
KC_PUBLICKEY: >-
15+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA4CcG7WPTCF4YLHxT3bs9ilcQ6SS+A2e/PiZ9hqR0noelBCsdW0SQGOhjE7nhl2lrZ0W/o80YKMzNZ42Hmc7p0sHU3RN95OCTHvyCazC/CKM2i+gD+cAspP/Ns+hOqNmxC/XIsgD3bZ2zobNMhNy3jgDaAsbs3kOGPIwkdo/vWeo7N6fZPxOgSp6JoGBDtehuyhQ/4y2f7TnyicIvHMuc2d7Bz4GalQ/ra+GspmZ/HqL93A6c8sDHa8fqC8O+gnzpBNsCOxJcq/i3NOaGrOFMCiJwsNVc2dUcY8epcW3pwakIRLlC6D7oawbxv7c3UsXoCt4XSC0hdjwXg5kxVXHoDQIDAQAB
16+
KC_REALM: cp1qly2d
17+
KC_SERVERURL: "https://dev.oidc.gov.bc.ca/auth"
18+
OBJECTSTORAGE_BUCKET: egejyy
19+
OBJECTSTORAGE_TEMP_EXPIRESIN: "300"
20+
OBJECTSTORAGE_ENDPOINT: "https://nrs.objectstore.gov.bc.ca"
21+
# OBJECTSTORAGE_KEY: ~
22+
SERVER_BODYLIMIT: 30mb
23+
# SERVER_LOGFILE: ~
24+
SERVER_LOGLEVEL: http
25+
SERVER_PORT: "3000"
26+
27+
patroni:
28+
enabled: true

.github/environments/values.prod.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
features:
3+
basicAuth: true
4+
oidcAuth: true
5+
6+
config:
7+
enabled: true
8+
configMap:
9+
BASICAUTH_ENABLED: "true"
10+
DB_ENABLED: "true"
11+
DB_PORT: "5432"
12+
KC_ENABLED: "true"
13+
KC_IDENTITYKEY: idir_user_guid
14+
KC_PUBLICKEY: >-
15+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwz4nqXMKFW+5WVFer7LalKRPeg7095S+fUurYFJQwpOQ5gMSRFvbLWNIVoXSrkRG33V0S3ZVfIwNkLPso/5l04sN9j7DgTwOTbWHZbkr/fL4R7eVi6AR5mjaakq4YgOeVGhBryUUyhLIRVUxnbKA36nph5nORHykDsccrEMRjtmVjzjo1a1Y23zU3nesEryq2fvbRKPaVQ+itQeia5ijZIUwzS4yeT2baF+xPFoMzJ4iHCaSzrYCTSNGLYHDm8T006kjfAcLfbbJjQtaPtgRVpi4g/F1eUrHLwO/AVycFiGjsJVEjPsYS44klubmSZWeATy57Y0wmR0WvNppnyIxewIDAQAB
16+
KC_REALM: cp1qly2d
17+
KC_SERVERURL: "https://oidc.gov.bc.ca/auth"
18+
OBJECTSTORAGE_BUCKET: egejyy
19+
OBJECTSTORAGE_TEMP_EXPIRESIN: "300"
20+
OBJECTSTORAGE_ENDPOINT: "https://nrs.objectstore.gov.bc.ca"
21+
# OBJECTSTORAGE_KEY: ~
22+
SERVER_BODYLIMIT: 30mb
23+
# SERVER_LOGFILE: ~
24+
SERVER_LOGLEVEL: http
25+
SERVER_PORT: "3000"
26+
27+
patroni:
28+
enabled: true

.github/environments/values.test.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
features:
3+
basicAuth: true
4+
oidcAuth: true
5+
6+
config:
7+
enabled: true
8+
configMap:
9+
BASICAUTH_ENABLED: "true"
10+
DB_ENABLED: "true"
11+
DB_PORT: "5432"
12+
KC_ENABLED: "true"
13+
KC_IDENTITYKEY: idir_user_guid
14+
KC_PUBLICKEY: >-
15+
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAry3hhpL3KT6Y2IXW+YJ3bw6krv/dA4VRP0Y/pLjI/D5fa53DhbCi6vD9nqdWl13gHZQRRpyp8jXLqhkYmmkuHoQtEg9f0pwR/JMXwT50zGrAEi/jEOri6wIEkTaVlKK2bVwNSPLREajVxqZdEGTlLDCOv6XjRdSVDLVfbtFGz+YtLlW+tPKqBo1gdIGmBe/lSs0g/HdiLZvVMCHKZBF3arPmTtRgv94GUBkCDu5aLZ0jHQNXfRbOxQV1BNCBXRPrchta4+PcDeAcYdfBmoJNBfX1qrqaGkXHnifmaAwAdhP/tZHiaYtyz31ywW1a2037lA0xY5IuI9s8OcqYPHybFwIDAQAB
16+
KC_REALM: cp1qly2d
17+
KC_SERVERURL: "https://test.oidc.gov.bc.ca/auth"
18+
OBJECTSTORAGE_BUCKET: egejyy
19+
OBJECTSTORAGE_TEMP_EXPIRESIN: "300"
20+
OBJECTSTORAGE_ENDPOINT: "https://nrs.objectstore.gov.bc.ca"
21+
# OBJECTSTORAGE_KEY: ~
22+
SERVER_BODYLIMIT: 30mb
23+
# SERVER_LOGFILE: ~
24+
SERVER_LOGLEVEL: http
25+
SERVER_PORT: "3000"
26+
27+
patroni:
28+
enabled: true

.github/workflows/docker-image.yaml

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)