Skip to content

2. Create Tag & Build/Deploy to Test #137

2. Create Tag & Build/Deploy to Test

2. Create Tag & Build/Deploy to Test #137

Workflow file for this run

name: 2. Create Tag & Build/Deploy to Test
on:
workflow_dispatch:
inputs:
tag:
type: string
description: Tag Version (incl. prefix; e.g. v1.2.3)
required: true
message:
type: string
description: Tag Message (e.g. Story Number)
required: true
env:
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
REGISTRY_USER: ${{ github.actor }}
REGISTRY_PASSWORD: ${{ github.token }}
jobs:
tag:
if: startsWith(github.ref, 'refs/heads/') == true
name: Create Tag
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Create Tag
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
git config commit.gpgsign false
git tag -a ${{ github.event.inputs.tag }} -m "${{ github.event.inputs.message }}"
git push origin ${{ github.event.inputs.tag }}
build-pre:
needs: [tag]
name: Create Tag Variable (remove V)
runs-on: ubuntu-latest
timeout-minutes: 1
outputs:
tag: ${{ steps.vars.outputs.tag }}
steps:
- name: Remove v from version for the docker tag
id: vars
run: |
vtag=${{ github.event.inputs.tag }}
echo "tag=${vtag//v}" >> $GITHUB_OUTPUT
build-static:
needs: [build-pre]
runs-on: ubuntu-latest
name: Build & Push Docker Static Image
environment:
name: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Build Static
id: build_image
uses: redhat-actions/buildah-build@v2.9
with:
context: .
layers: true
image: drivebc-static
tags: latest latest-test ${{ github.sha }} ${{ needs.build-pre.outputs.tag }}
labels: |
app=drivebc
containerfiles: ./compose/frontend/StaticBuild
build-args: |
DEBUG_BUILD=false
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2.7
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
build-backend:
needs: [build-pre]
runs-on: ubuntu-latest
name: Build & Push Docker Backend Image
environment: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Build Backend
id: build_image
uses: redhat-actions/buildah-build@v2.9
with:
image: drivebc-django
tags: latest latest-test ${{ github.sha }} ${{ needs.build-pre.outputs.tag }}
labels: |
app=drivebc
containerfiles: ./compose/backend/Dockerfile
build-args:
DEBUG_BUILD=true
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2.7
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
build-image-caching:
needs: [build-pre]
runs-on: ubuntu-latest
name: Build & Push Docker Image-Caching Image
environment: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Build Image Caching
id: build_image
uses: redhat-actions/buildah-build@v2.9
with:
image: drivebc-image-caching
tags: latest latest-test ${{ github.sha }} ${{ needs.build-pre.outputs.tag }}
labels: |
app=drivebc
containerfiles: ./compose/caching/Dockerfile
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2.7
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
build-redis:
needs: [build-pre]
runs-on: ubuntu-latest
name: Build & Push Docker Redis Image
environment: test
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Build Redis
id: build_image
uses: redhat-actions/buildah-build@v2.9
with:
image: drivebc-redis
tags: latest latest-test ${{ github.sha }} ${{ needs.build-pre.outputs.tag }}
labels: |
app=drivebc
containerfiles: ./compose/redis/Dockerfile
- name: Push to Github Packages
uses: redhat-actions/push-to-registry@v2.7
with:
image: ${{ steps.build_image.outputs.image }}
tags: ${{ steps.build_image.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.REGISTRY_USER }}
password: ${{ env.REGISTRY_PASSWORD }}
versionUpdate:
needs: [build-pre, build-static, build-backend, build-image-caching, build-redis]
runs-on: ubuntu-latest
name: Deploy Latest Images
environment:
name: test
url: https://test-drivebc.apps.gold.devops.gov.bc.ca
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref_name }}
- name: Authenticate and set context
uses: redhat-actions/oc-login@v1
with:
openshift_server_url: ${{ secrets.OPENSHIFT_SERVER }}
openshift_token: ${{ secrets.OPENSHIFT_TOKEN }}
namespace: ${{ env.OPENSHIFT_NAMESPACE }}
insecure_skip_tls_verify: true
- name: Helm upgrade on OpenShift Environment
run: |
helm dependency update ./infrastructure/main
helm upgrade test-drivebc -f ./infrastructure/main/values-test.yaml ./infrastructure/main --set django.image.tag="${{ needs.build-pre.outputs.tag }}" --set image-caching.image.tag="${{ needs.build-pre.outputs.tag }}" --set redis.image.tag="${{ needs.build-pre.outputs.tag }}" --set static.image.tag="${{ needs.build-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.build-pre.outputs.tag }}"