Skip to content

Workflow file for this run

name: CD/CD Pipeline to DEV
env:
OC_URL: ${{ secrets.OC_URL }}
OC_SERVICE_ACCOUNT: ${{ secrets.OC_SERVICE_ACCOUNT }}
OC_TOKEN: ${{ secrets.OC_TOKEN }}
OC_NAMESPACE: ${{ secrets.OC_NAMESPACE }}
# IMAGE_REGISTRY: ${{ secrets.IMAGE_REGISTRY }}
# IMAGE_REGISTRY_USER: ${{ secrets.IMAGE_REGISTRY_USER }}
# IMAGE_REGISTRY_PASSWORD: ${{ secrets.IMAGE_REGISTRY_PASSWORD }}
# Registries such as GHCR, Quay.io, and Docker Hub are supported.
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_REGISTRY_USER: ${{ github.actor }}
IMAGE_REGISTRY_PASSWORD: ${{ github.token }}
DOCKER_ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca/docker-remote
ARTIFACTORY_REPO: artifacts.developer.gov.bc.ca
API_IMAGE_NAME: api
API_NAME: api
APP_IMAGE_NAME: dashboard
IMAGE_TAG: latest
DEPLOY_TO: dev
on:
pull_request_target:
branches:
- dev
types:
- closed
push:
branches:
- 146
jobs:
build-api:
name: API - Build Image
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
packages: write
env:
working-directory: ./
steps:
- name: Checkout Source Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Build API
id: build-api
uses: redhat-actions/buildah-build@v2
with:
image: ${{ env.API_IMAGE_NAME }}
tags: ${{ env.IMAGE_TAG }}
dockerfiles: |
./src/api/Dockerfile
context: ./
# https://github.com/redhat-actions/push-to-registry#readme
- name: Push API to registry
id: push-image-backend
uses: redhat-actions/push-to-registry@v2
with:
image: ${{ steps.build-api.outputs.image }}
tags: ${{ steps.build-api.outputs.tags }}
registry: ${{ env.IMAGE_REGISTRY }}
username: ${{ env.IMAGE_REGISTRY_USER }}
password: ${{ env.IMAGE_REGISTRY_PASSWORD }}
# - name: Login to Openshift
# run: |
# set -eux
# oc login --token=${{ env.OC_TOKEN }} --server=${{ env.OC_URL }}/${{ env.OC_NAMESPACE }}
# oc project ${{ env.OC_NAMESPACE }}
# - name: Install oc
# uses: redhat-actions/openshift-tools-installer@v1
# with:
# oc: 4
# # https://github.com/redhat-actions/oc-login#readme
# # - uses: actions/checkout@v2
# - name: Deploy
# run: |
# set -eux
# # Login to OpenShift and select project
# oc login --token=${{ env.OC_TOKEN }} --server=${{ env.OC_URL }}
# oc project ${{ env.OC_NAMESPACE }}
# # Cancel any rollouts in progress
# oc rollout cancel dc/${{ env.API_NAME }} 2> /dev/null \
# || true && echo "No rollout in progress"
# # Create the image stream if it doesn't exist
# oc create imagestream ${{ env.REPO_NAME }} 2> /dev/null || true && echo "Backend image stream in place"
# oc tag ${{ steps.push-image-backend.outputs.registry-path }} ${{ env.REPO_NAME }}-${{ env.APP_NAME_BACKEND }}-${{ env.BRANCH }}:${{ env.DEPLOY_TO }}
# # Process and apply deployment template
# oc process -f tools/openshift/d365api.dc.yaml -p APP_NAME=${{ env.API_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p BRANCH=${{ env.BRANCH }} -p NAMESPACE=${{ env.OC_NAMESPACE }} -p TAG=${{ env.TAG }} -p MIN_REPLICAS=${{ env.MIN_REPLICAS }} -p MAX_REPLICAS=${{ env.MAX_REPLICAS }} -p MIN_CPU=${{ env.MIN_CPU }} -p MAX_CPU=${{ env.MAX_CPU }} -p MIN_MEM=${{ env.MIN_MEM }} -p MAX_MEM=${{ env.MAX_MEM }}\
# | oc apply -f -
# # Start rollout (if necessary) and follow it
# oc rollout latest dc/${{ env.API_NAME }}-${{ env.APP_NAME_BACKEND }}-${{ env.BRANCH }} 2> /dev/null \
# || true && echo "Rollout in progress"
# # Get status, returns 0 if rollout is successful
# oc rollout status dc/${{ env.API_NAME }}-${{ env.APP_NAME_BACKEND }}-${{ env.BRANCH }}