Skip to content

Commit 3c3519d

Browse files
committed
wip github workflows updates
1 parent 9099137 commit 3c3519d

9 files changed

Lines changed: 415 additions & 413 deletions

File tree

.github/actions/build-push-container/action.yaml

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

.github/actions/deploy-to-environment/action.yaml

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

.github/workflows/builder.yaml

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
name: Builder
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
context:
7+
description: 'Effective Working Directory'
8+
required: true
9+
type: string
10+
default: "./"
11+
image_name:
12+
description: 'Image Name'
13+
required: true
14+
type: string
15+
github_username:
16+
description: 'Github Container Registry Username'
17+
required: true
18+
type: string
19+
dockerhub_username:
20+
description: 'Dockerhub Container Registry Username'
21+
required: false
22+
type: string
23+
dockerhub_organization:
24+
description: 'Dockerhub Container Registry Organization'
25+
required: false
26+
type: string
27+
default: bcgovimages
28+
secrets:
29+
github_token:
30+
description: 'Github Container Registry Authorization Token'
31+
required: true
32+
dockerhub_token:
33+
description: 'Dockerhub Container Registry Authorization Token'
34+
required: false
35+
outputs:
36+
image_tag:
37+
description: 'Docker image tag'
38+
value: ${{ jobs.builder.outputs.image_tag }}
39+
40+
jobs:
41+
builder:
42+
name: Builder
43+
permissions:
44+
packages: write # for docker/build-push-action to push images to GitHub Container Registry
45+
runs-on: ubuntu-latest
46+
timeout-minutes: 10
47+
outputs:
48+
image_tag: ${{ steps.meta.outputs.version }}
49+
steps:
50+
- name: Checkout repository
51+
uses: actions/checkout@v6
52+
53+
- name: Parse Input Values
54+
shell: bash
55+
run: |
56+
echo "GH_USERNAME=$(tr '[:upper:]' '[:lower:]' <<< '${{ inputs.github_username }}')" >> $GITHUB_ENV
57+
echo "HAS_DOCKERHUB=${{ inputs.dockerhub_username != '' && secrets.dockerhub_token != '' }}" >> $GITHUB_ENV
58+
59+
- name: Login to Github Container Registry
60+
uses: docker/login-action@v4
61+
with:
62+
registry: ghcr.io
63+
username: ${{ env.GH_USERNAME }}
64+
password: ${{ secrets.github_token }}
65+
66+
- name: Login to Dockerhub Container Registry
67+
if: env.HAS_DOCKERHUB == 'true'
68+
uses: docker/login-action@v4
69+
with:
70+
registry: docker.io
71+
username: ${{ inputs.dockerhub_username }}
72+
password: ${{ secrets.dockerhub_token }}
73+
74+
- name: Prepare Container Metadata tags
75+
id: meta
76+
uses: docker/metadata-action@v6
77+
with:
78+
images: |
79+
ghcr.io/${{ env.GH_USERNAME }}/${{ inputs.image_name }}
80+
docker.io/${{ inputs.dockerhub_organization }}/${{ inputs.image_name }},enable=${{ env.HAS_DOCKERHUB }}
81+
# Always updates the 'latest' tag
82+
flavor: |
83+
latest=true
84+
# Creates tags based off of branch names and semver tags
85+
tags: |
86+
type=ref,event=branch
87+
type=ref,event=pr
88+
type=semver,pattern={{version}}
89+
type=semver,pattern={{major}}.{{minor}}
90+
type=semver,pattern={{major}}
91+
type=sha
92+
93+
- name: Build and Push to Container Registry
94+
id: builder
95+
uses: docker/build-push-action@v7
96+
with:
97+
context: ${{ inputs.context }}
98+
push: true
99+
tags: ${{ steps.meta.outputs.tags }}
100+
labels: ${{ steps.meta.outputs.labels }}
101+
annotations: ${{ steps.meta.outputs.annotations }}
102+
build-args: |
103+
GIT_COMMIT=${{ github.sha }}
104+
105+
- name: Inspect Docker Image
106+
shell: bash
107+
run: |
108+
docker image inspect ghcr.io/${{ env.GH_USERNAME }}/${{ inputs.image_name }}:latest

.github/workflows/deployer.yaml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Deployer
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
app_name:
7+
description: 'Application name'
8+
required: true
9+
type: string
10+
acronym:
11+
description: 'Application acronym'
12+
required: true
13+
type: string
14+
environment:
15+
description: 'Logical Github Environment'
16+
required: true
17+
type: string
18+
image_tag:
19+
description: 'Docker image tag to deploy'
20+
required: true
21+
type: string
22+
job_name:
23+
description: 'Job/Instance name'
24+
required: true
25+
type: string
26+
namespace_prefix:
27+
description: 'Openshift Namespace common prefix'
28+
required: true
29+
type: string
30+
namespace_environment:
31+
description: 'Openshift Namespace environment suffix'
32+
required: true
33+
type: string
34+
secrets:
35+
openshift_server:
36+
description: 'Openshift API Endpoint'
37+
required: true
38+
openshift_token:
39+
description: 'Openshift Service Account Token'
40+
required: true
41+
42+
jobs:
43+
infra:
44+
name: ${{ inputs.environment }} ${{ inputs.job_name }}
45+
environment:
46+
name: ${{ inputs.environment }}
47+
permissions:
48+
contents: read # This is required for actions/checkout
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Checkout repository
52+
uses: actions/checkout@v6
53+
54+
- name: Login to OpenShift Cluster
55+
uses: bcgov/action-oc-runner@d2fc921aaa9d70684c186dbb7754e6985d44d86f # v1.4.1
56+
with:
57+
oc_server: ${{ secrets.openshift_server }}
58+
oc_token: ${{ secrets.openshift_token }}
59+
oc_namespace: ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}
60+
61+
- name: Helm Deploy
62+
shell: bash
63+
run: >-
64+
helm upgrade --install --atomic ${{ inputs.job_name }} ${{ inputs.app_name }}
65+
--namespace ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }}
66+
--repo https://bcgov.github.io/nr-permitconnect-navigator-service/
67+
--values ./.github/environments/values.${{ inputs.environment }}.yaml
68+
--set image.repository=ghcr.io/${{ github.repository_owner }}
69+
--set image.tag=${{ inputs.image_tag }}
70+
--set route.host=${{ inputs.acronym }}-${{ inputs.namespace_environment }}-${{ inputs.job_name }}.apps.silver.devops.gov.bc.ca
71+
--timeout 10m
72+
--wait
73+
74+
- name: Wait on Deployment
75+
shell: bash
76+
run: |
77+
oc rollout --namespace ${{ inputs.namespace_prefix }}-${{ inputs.namespace_environment }} status dc/${{ inputs.app_name }}-${{ inputs.job_name }} --watch=true

.github/workflows/on-pr-closed.yaml

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

0 commit comments

Comments
 (0)