Deploy to TEST #58
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: Deploy to TEST | |
env: | |
# 🖊️ EDIT your repository secrets to log into your OpenShift cluster and set up the context. | |
# See https://github.com/redhat-actions/oc-login#readme for how to retrieve these values. | |
# To get a permanent token, refer to https://github.com/redhat-actions/oc-login/wiki/Using-a-Service-Account-for-GitHub-Actions | |
OPENSHIFT_SERVER: '${{ secrets.OPENSHIFT_SERVER }}' | |
OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | |
OPENSHIFT_NAMESPACE_TEST: '${{ secrets.ECAS_NAMESPACE_NO_ENV }}-test' | |
OPENSHIFT_NAMESPACE_DEV: '${{ secrets.ECAS_NAMESPACE_NO_ENV }}-dev' | |
REPO_NAME: educ-ecas | |
APP_NAME: ecas | |
APP_NAME_FRONTEND: ecas-frontend | |
APP_NAME_API: ecas-api | |
APP_NAME_CAS: cas-api | |
NAMESPACE: '${{ secrets.ECAS_NAMESPACE_NO_ENV }}' | |
IMAGE_NAME_FRONTEND: ecas-frontend | |
IMAGE_NAME_API: ecas-api | |
IMAGE_NAME_CAS: cas-api | |
MIN_REPLICAS: '1' | |
MAX_REPLICAS: '2' | |
MIN_CPU: 300m | |
MAX_CPU: 600m | |
MIN_MEM: 250Mi | |
MAX_MEM: 500Mi | |
#frontend config maps vars | |
APP_DEBUG: 'FALSE' | |
DYNAMICSBASEURL: http://ecas-api:8080/api | |
DOCUMENTROOT: /public | |
#ecas api config maps vars | |
ASPNETCORE_ENVIRONMENT: 'Staging' | |
DYNAMICSAUTHENTICATIONSETTINGS__ACTIVEENVIRONMENT: Cloud | |
DYNAMICSAUTHENTICATIONSETTINGS__CLOUDWEBAPIURL: https://ecastest.api.crm3.dynamics.com/api/data/v9.2/ | |
DYNAMICSAUTHENTICATIONSETTINGS__CLOUDREDIRECTURL: https://localhost | |
DYNAMICSAUTHENTICATIONSETTINGS__CLOUDRESOURCEURL: https://ecastest.crm3.dynamics.com/api/data/ | |
DYNAMICSAUTHENTICATIONSETTINGS__CLOUDBASEURL: https://ecastest.api.crm3.dynamics.com | |
#cas api config maps vars | |
ASPNETCORE_ENVIRONMENT_CAS: 'Production' | |
CAS_API_SERVER: https://cfs-systws.cas.gov.bc.ca:7026 | |
CAS_TOKEN_URI: /ords/cas/oauth/token | |
CAS_INVOICE_URI: /ords/cas/cfs/apinvoice/ | |
HOST_ROUTE: '${{ secrets.SITE_URL }}' | |
BRANCH: "master" | |
CA_CERT: ${{ secrets.CA_CERT }} | |
CERTIFICATE: ${{ secrets.CERT }} | |
PRIVATE_KEY: ${{ secrets.PRIV_KEY }} | |
ENV: "test" | |
on: | |
# https://docs.github.com/en/actions/reference/events-that-trigger-workflows | |
workflow_dispatch: | |
jobs: | |
deploy-to-openshift-test: | |
name: Deploy to OpenShift TEST | |
runs-on: ubuntu-24.04 | |
environment: test | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Get latest tag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
id: get-latest-tag | |
- 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.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} | |
oc project ${{ env.OPENSHIFT_NAMESPACE_TEST }} | |
# Cancel any rollouts in progress | |
oc rollout cancel dc/${{ env.IMAGE_NAME_FRONTEND }} 2> /dev/null || true && echo "No rollout in progress" | |
oc rollout cancel dc/${{ env.IMAGE_NAME_API }} 2> /dev/null || true && echo "No ecas api rollout in progress" | |
oc rollout cancel dc/${{ env.IMAGE_NAME_CAS }} 2> /dev/null || true && echo "No cas api rollout in progress" | |
oc tag ${{ env.OPENSHIFT_NAMESPACE_DEV }}/${{ env.REPO_NAME }}-frontend:${{ steps.get-latest-tag.outputs.tag }} \ | |
${{ env.OPENSHIFT_NAMESPACE_TEST }}/${{ env.REPO_NAME }}-frontend:${{ steps.get-latest-tag.outputs.tag }} | |
oc tag ${{ env.OPENSHIFT_NAMESPACE_DEV }}/${{ env.REPO_NAME }}-api:${{ steps.get-latest-tag.outputs.tag }} \ | |
${{ env.OPENSHIFT_NAMESPACE_TEST }}/${{ env.REPO_NAME }}-api:${{ steps.get-latest-tag.outputs.tag }} | |
oc tag ${{ env.OPENSHIFT_NAMESPACE_DEV }}/${{ env.REPO_NAME }}-cas-api:${{ steps.get-latest-tag.outputs.tag }} \ | |
${{ env.OPENSHIFT_NAMESPACE_TEST }}/${{ env.REPO_NAME }}-cas-api:${{ steps.get-latest-tag.outputs.tag }} | |
curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/openshift/update-configmap.sh | bash /dev/stdin "${{ env.REPO_NAME }}" "${{ env.OPENSHIFT_NAMESPACE_DEV }}" "${{env.APP_DEBUG}}" "${{env.DOCUMENTROOT}}" "${{ env.DYNAMICSBASEURL}}" "${{env.ASPNETCORE_ENVIRONMENT}}" "${{env.DYNAMICSAUTHENTICATIONSETTINGS__ACTIVEENVIRONMENT}}" "${{env.DYNAMICSAUTHENTICATIONSETTINGS__CLOUDWEBAPIURL}}" "${{env.DYNAMICSAUTHENTICATIONSETTINGS__CLOUDREDIRECTURL}}" "${{env.DYNAMICSAUTHENTICATIONSETTINGS__CLOUDRESOURCEURL}}" "${{env.DYNAMICSAUTHENTICATIONSETTINGS__CLOUDBASEURL}}" "${{env.ASPNETCORE_ENVIRONMENT_CAS}}" "${{env.CAS_API_SERVER}}" "${{env.CAS_TOKEN_URI}}" "${{env.CAS_INVOICE_URI}}" | |
# Process and apply deployment template | |
oc process -f ./openshift/templates/ecas-frontend/frontend.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ steps.get-latest-tag.outputs.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 }} -p HOST_ROUTE=${{ env.HOST_ROUTE}} -p CA_CERT="${{ env.CA_CERT }}" -p CERTIFICATE="${{ env.CERTIFICATE }}" -p PRIVATE_KEY="${{ env.PRIVATE_KEY }}" -p ENV="${{env.ENV}}"| oc apply -f - | |
oc process -f ./openshift/templates/ecas-api/api.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ steps.get-latest-tag.outputs.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 }} -p HOST_ROUTE=${{ env.HOST_ROUTE }} \ | |
| oc apply -f - | |
oc process -f ./openshift/templates/cas-api/cas-api.dc.yaml -p APP_NAME=${{ env.APP_NAME }} -p REPO_NAME=${{ env.REPO_NAME }} -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE_TEST }} -p TAG=${{ steps.get-latest-tag.outputs.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 }} -p HOST_ROUTE=${{ env.HOST_ROUTE }}\ | |
| oc apply -f - | |
# Start rollout (if necessary) and follow it | |
oc rollout latest dc/${{ env.APP_NAME_FRONTEND }} 2> /dev/null || true && echo "Rollout Front End in progress" | |
oc rollout latest dc/${{ env.APP_NAME_API }} 2> /dev/null || true && echo "Rollout ECAS API in progress" | |
oc rollout latest dc/${{ env.APP_NAME_CAS }} 2> /dev/null || true && echo "Rollout CAS API in progress" | |
oc logs dc/${{ env.IMAGE_NAME_FRONTEND }} | |
oc logs dc/${{ env.IMAGE_NAME_API }} | |
oc logs dc/${{ env.IMAGE_NAME_CAS }} | |
# Get status, returns 0 if rollout is successful | |
oc rollout status dc/${{ env.IMAGE_NAME_FRONTEND }} | |
oc rollout status dc/${{ env.IMAGE_NAME_API }} | |
oc rollout status dc/${{ env.IMAGE_NAME_CAS }} | |