3. Create Tag & Build/Deploy to UAT #41
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: 3. Promote from Test to UAT | |
on: | |
workflow_dispatch: #Make sure you select a tag and not the branch | |
env: | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
REGISTRY_USER: ${{ github.actor }} | |
REGISTRY_PASSWORD: ${{ github.token }} | |
permissions: | |
packages: write | |
jobs: | |
deploy-pre: | |
runs-on: ubuntu-latest | |
name: Create Tag Variable (remove V) | |
timeout-minutes: 1 | |
outputs: | |
tag: ${{ steps.vars.outputs.tag }} | |
steps: | |
- name: Fail on branches | |
run: exit 1 | |
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | |
- name: Remove v from version for the docker tag | |
id: vars | |
run: | | |
vtag=${{ github.ref_name }} | |
echo "tag=${vtag//v}" >> $GITHUB_OUTPUT | |
#This job adds 'latest-uat' docker tags to the existing image so it's always clear which image is current for a particular environment | |
addDockerTag: | |
needs: [deploy-pre] | |
runs-on: ubuntu-latest | |
name: Add latest-uat Tag | |
steps: | |
- name: Add latest-uat tag to django image | |
uses: shrink/actions-docker-registry-tag@v3 | |
with: | |
registry: ghcr.io | |
repository: ${{ github.repository }}/drivebc-django | |
target: ${{ needs.deploy-pre.outputs.tag }} | |
tags: | | |
latest-uat | |
- name: Add latest-uat tag to static image | |
uses: shrink/actions-docker-registry-tag@v3 | |
with: | |
registry: ghcr.io | |
repository: ${{ github.repository }}/drivebc-static | |
target: ${{ needs.deploy-pre.outputs.tag }} | |
tags: | | |
latest-uat | |
- name: Add latest-uat tag to image-caching image | |
uses: shrink/actions-docker-registry-tag@v3 | |
with: | |
registry: ghcr.io | |
repository: ${{ github.repository }}/drivebc-image-caching | |
target: ${{ needs.deploy-pre.outputs.tag }} | |
tags: | | |
latest-uat | |
- name: Add latest-uat tag to redis image | |
uses: shrink/actions-docker-registry-tag@v3 | |
with: | |
registry: ghcr.io | |
repository: ${{ github.repository }}/drivebc-redis | |
target: ${{ needs.deploy-pre.outputs.tag }} | |
tags: | | |
latest-uat | |
deploy: | |
needs: [deploy-pre] | |
runs-on: ubuntu-latest | |
name: Promote Images to OpenShift | |
environment: | |
name: uat | |
url: https://uat-drivebc.apps.gold.devops.gov.bc.ca/ | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
- 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 uat-drivebc -f ./infrastructure/main/values-uat.yaml ./infrastructure/main --set django.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set image-caching.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set redis.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set static.image.tag="${{ needs.deploy-pre.outputs.tag }}" --set tasks.image.tag="${{ needs.deploy-pre.outputs.tag }}" |