From 584199522f16f036d827f4d6eb8bc6bf73810026 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Thu, 31 Oct 2024 14:14:31 -0700 Subject: [PATCH 1/5] feat: add efx environment and adjust adjacent deply flows --- .../deploy-to-openshift-backend-efx.yml | 165 ++++++++++++++++++ .../deploy-to-openshift-backend-prod.yml | 2 +- .../deploy-to-openshift-backend-uat.yml | 4 +- .../deploy-to-openshift-frontend-efx.yml | 159 +++++++++++++++++ .../deploy-to-openshift-frontend-prod.yml | 2 +- .../deploy-to-openshift-frontend-uat.yml | 6 +- 6 files changed, 330 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/deploy-to-openshift-backend-efx.yml create mode 100644 .github/workflows/deploy-to-openshift-frontend-efx.yml diff --git a/.github/workflows/deploy-to-openshift-backend-efx.yml b/.github/workflows/deploy-to-openshift-backend-efx.yml new file mode 100644 index 000000000..27b4c27c4 --- /dev/null +++ b/.github/workflows/deploy-to-openshift-backend-efx.yml @@ -0,0 +1,165 @@ +name: 4 EFX - Deploy Backend + +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 }} + # EDIT to set the kube context's namespace after login. Leave blank to use your user's default namespace. + OPENSHIFT_NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }}-efx + + SPLUNK_TOKEN: ${{ secrets.SPLUNK_TOKEN }} + + # EDIT to change the image registry settings. + # 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 + + APP_NAME: 'ccof' + REPO_NAME: "educ-ccof" + #grabs the branch name from github dynamically + BRANCH: ${{ github.ref_name }} + IMAGE_NAME: "backend" + APP_ENVIRONMENT: "efx" + + NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }} + + MIN_REPLICAS: "2" + MAX_REPLICAS: "3" + MIN_CPU: "50m" + MAX_CPU: "250m" + MIN_MEM: "200Mi" + MAX_MEM: "700Mi" + # SITE_URL should have no scheme or port. It will be prepended with https:// + HOST_ROUTE: ${{ secrets.SITE_URL }} + +on: + workflow_dispatch: + +jobs: + openshift-ci-cd: + name: Deploy Backend to EFX + runs-on: ubuntu-24.04 + environment: efx + + outputs: + ROUTE: ${{ steps.deploy-and-expose.outputs.route }} + SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} + + steps: + - name: Check for required secrets + uses: actions/github-script@v4 + with: + script: | + const secrets = { + OPENSHIFT_SERVER: `${{ secrets.OPENSHIFT_SERVER }}`, + OPENSHIFT_TOKEN: `${{ secrets.OPENSHIFT_TOKEN }}`, + }; + + const GHCR = "ghcr.io"; + if (`${{ env.IMAGE_REGISTRY }}`.startsWith(GHCR)) { + core.info(`Image registry is ${GHCR} - no registry password required`); + } + else { + core.info("A registry password is required"); + secrets["IMAGE_REGISTRY_PASSWORD"] = `${{ secrets.IMAGE_REGISTRY_PASSWORD }}`; + } + + const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => { + if (value.length === 0) { + core.error(`Secret "${name}" is not set`); + return true; + } + core.info(`Secret "${name}" is set`); + return false; + }); + + if (missingSecrets.length > 0) { + core.setFailed(`At least one required secret is not set in the repository. \n` + + "You can add it using:\n" + + "GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + + "GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" + + "Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); + } + else { + core.info(`All the required secrets are set`); + } + + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH }} + + - 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.16 + + - 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 }} + # Cancel any rollouts in progress + oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + || true && echo "No rollout in progress" + + # Create tag for TEST env from DEV env image + oc tag \ + ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} \ + ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} + + # Process and apply deployment template + oc process \ + -f tools/openshift/backend.dc.yaml \ + -p APP_NAME=${{ env.APP_NAME }} \ + -p REPO_NAME=${{ env.REPO_NAME }} \ + -p BRANCH=${{ env.BRANCH }} \ + -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE }} \ + -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 APP_ENVIRONMENT=${{ env.APP_ENVIRONMENT }} \ + | oc apply -f - + + # Process update-configmap + curl -s https://raw.githubusercontent.com/bcgov/${{ env.REPO_NAME }}/${{ env.BRANCH }}/tools/config/update-configmap.sh \ + | bash /dev/stdin \ + ${{ env.APP_ENVIRONMENT }} \ + ${{ env.APP_NAME }} \ + ${{ secrets.CCOF_NAMESPACE_NO_ENV }} \ + ${{ secrets.COMMON_NAMESPACE_NO_ENV }} \ + ${{ secrets.SOAM_CLIENT_ID }} \ + ${{ secrets.SOAM_CLIENT_ID_IDIR }} \ + ${{ secrets.SOAM_CLIENT_SECRET }} \ + ${{ secrets.SOAM_CLIENT_SECRET_IDIR }} \ + ${{ secrets.SPLUNK_TOKEN }} \ + ${{ secrets.REDIS_PASSWORD }} \ + ${{ secrets.D365_API_PREFIX }} + + # Start rollout (if necessary) and follow it + oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \ + || true && echo "Rollout in progress" + + # Get status, returns 0 if rollout is successful + oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} + + - name: ZAP Scan + uses: zaproxy/action-full-scan@v0.8.0 + with: + target: 'https://${{ env.HOST_ROUTE }}/api' diff --git a/.github/workflows/deploy-to-openshift-backend-prod.yml b/.github/workflows/deploy-to-openshift-backend-prod.yml index 5a6d42978..1fb4bbf08 100644 --- a/.github/workflows/deploy-to-openshift-backend-prod.yml +++ b/.github/workflows/deploy-to-openshift-backend-prod.yml @@ -1,4 +1,4 @@ -name: 4 PROD - Deploy Backend +name: 5 PROD - Deploy Backend env: # EDIT your repository secrets to log into your OpenShift cluster and set up the context. diff --git a/.github/workflows/deploy-to-openshift-backend-uat.yml b/.github/workflows/deploy-to-openshift-backend-uat.yml index 2f9140d65..408166f92 100644 --- a/.github/workflows/deploy-to-openshift-backend-uat.yml +++ b/.github/workflows/deploy-to-openshift-backend-uat.yml @@ -29,8 +29,8 @@ env: NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }} - MIN_REPLICAS: "3" - MAX_REPLICAS: "5" + MIN_REPLICAS: "2" + MAX_REPLICAS: "3" MIN_CPU: "50m" MAX_CPU: "250m" MIN_MEM: "200Mi" diff --git a/.github/workflows/deploy-to-openshift-frontend-efx.yml b/.github/workflows/deploy-to-openshift-frontend-efx.yml new file mode 100644 index 000000000..4eb07cd69 --- /dev/null +++ b/.github/workflows/deploy-to-openshift-frontend-efx.yml @@ -0,0 +1,159 @@ +name: 4 EFX - Deploy Frontend + +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 }} + # EDIT to set the kube context's namespace after login. Leave blank to use your user's default namespace. + OPENSHIFT_NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }}-test + + # SPLUNK_TOKEN: ${{ secrets.SPLUNK_TOKEN }} + + # EDIT to change the image registry settings. + # 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 + + APP_NAME: 'ccof' + REPO_NAME: "educ-ccof" + #grabs the branch name from github dynamically + BRANCH: ${{ github.ref_name }} + IMAGE_NAME: "frontend" + APP_ENVIRONMENT: "efx" + + NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }} + + MIN_REPLICAS: "2" + MAX_REPLICAS: "3" + MIN_CPU: "50m" + MAX_CPU: "100m" + MIN_MEM: "200Mi" + MAX_MEM: "250Mi" + # SITE_URL should have no scheme or port. It will be prepended with https:// + HOST_ROUTE: ${{ secrets.SITE_URL }} + CA_CERT: ${{ secrets.CA_CERT }} + CERTIFICATE: ${{ secrets.CERTIFICATE }} + PRIVATE_KEY: ${{ secrets.PRIVATE_KEY }} + +on: + workflow_dispatch: + +jobs: + openshift-ci-cd: + name: Deploy Frontend to EFX + runs-on: ubuntu-24.04 + environment: efx + + outputs: + ROUTE: ${{ steps.deploy-and-expose.outputs.route }} + SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} + + steps: + - name: Check for required secrets + uses: actions/github-script@v4 + with: + script: | + const secrets = { + OPENSHIFT_SERVER: `${{ secrets.OPENSHIFT_SERVER }}`, + OPENSHIFT_TOKEN: `${{ secrets.OPENSHIFT_TOKEN }}`, + }; + + const GHCR = "ghcr.io"; + if (`${{ env.IMAGE_REGISTRY }}`.startsWith(GHCR)) { + core.info(`Image registry is ${GHCR} - no registry password required`); + } + else { + core.info("A registry password is required"); + secrets["IMAGE_REGISTRY_PASSWORD"] = `${{ secrets.IMAGE_REGISTRY_PASSWORD }}`; + } + + const missingSecrets = Object.entries(secrets).filter(([ name, value ]) => { + if (value.length === 0) { + core.error(`Secret "${name}" is not set`); + return true; + } + core.info(`Secret "${name}" is set`); + return false; + }); + + if (missingSecrets.length > 0) { + core.setFailed(`At least one required secret is not set in the repository. \n` + + "You can add it using:\n" + + "GitHub UI: https://docs.github.com/en/actions/reference/encrypted-secrets#creating-encrypted-secrets-for-a-repository \n" + + "GitHub CLI: https://cli.github.com/manual/gh_secret_set \n" + + "Also, refer to https://github.com/redhat-actions/oc-login#getting-started-with-the-action-or-see-example"); + } + else { + core.info(`All the required secrets are set`); + } + + - name: Check out repository + uses: actions/checkout@v2 + with: + ref: ${{ env.BRANCH }} + + - 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.16 + + - 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 }} + # Cancel any rollouts in progress + oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + || true && echo "No rollout in progress" + + # Create tag for TEST env from DEV env image + oc tag \ + ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} \ + ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} + + # Process and apply deployment template + oc process \ + -f tools/openshift/frontend.dc.yaml \ + -p APP_NAME=${{ env.APP_NAME }} \ + -p REPO_NAME=${{ env.REPO_NAME }} \ + -p BRANCH=${{ env.BRANCH }} \ + -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE }} \ + -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 APP_ENVIRONMENT=${{ env.APP_ENVIRONMENT }} \ + -p BANNER_COLOR=${{ vars.BANNER_COLOR }} \ + -p BANNER_ENVIRONMENT=${{ vars.BANNER_ENVIRONMENT }} \ + -p VUE_APP_BCEID_REG_URL='${{ secrets.VUE_APP_BCEID_REG_URL }}' \ + | oc apply -f - + + # Start rollout (if necessary) and follow it + oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + || true && echo "Rollout in progress" + + # Get status, returns 0 if rollout is successful + oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} + + - name: ZAP Scan + uses: zaproxy/action-full-scan@v0.8.0 + with: + target: 'https://${{ env.HOST_ROUTE }}' diff --git a/.github/workflows/deploy-to-openshift-frontend-prod.yml b/.github/workflows/deploy-to-openshift-frontend-prod.yml index 24a105766..1c602fba0 100644 --- a/.github/workflows/deploy-to-openshift-frontend-prod.yml +++ b/.github/workflows/deploy-to-openshift-frontend-prod.yml @@ -1,4 +1,4 @@ -name: 4 PROD - Deploy Frontend +name: 5 PROD - Deploy Frontend env: # EDIT your repository secrets to log into your OpenShift cluster and set up the context. diff --git a/.github/workflows/deploy-to-openshift-frontend-uat.yml b/.github/workflows/deploy-to-openshift-frontend-uat.yml index 462d34035..4003ecc2d 100644 --- a/.github/workflows/deploy-to-openshift-frontend-uat.yml +++ b/.github/workflows/deploy-to-openshift-frontend-uat.yml @@ -29,10 +29,8 @@ env: NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }} - - - MIN_REPLICAS: "3" - MAX_REPLICAS: "5" + MIN_REPLICAS: "2" + MAX_REPLICAS: "3" MIN_CPU: "50m" MAX_CPU: "100m" MIN_MEM: "200Mi" From 349fe68a8755b2084517db35bafdbda38a9768d0 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Tue, 19 Nov 2024 14:51:06 -0800 Subject: [PATCH 2/5] feat: add explicit deployment tag to efx --- .../deploy-to-openshift-backend-efx.yml | 22 ++++++++++++------- .../deploy-to-openshift-frontend-efx.yml | 21 ++++++++++++------ 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/.github/workflows/deploy-to-openshift-backend-efx.yml b/.github/workflows/deploy-to-openshift-backend-efx.yml index 27b4c27c4..6c5464163 100644 --- a/.github/workflows/deploy-to-openshift-backend-efx.yml +++ b/.github/workflows/deploy-to-openshift-backend-efx.yml @@ -40,7 +40,11 @@ env: on: workflow_dispatch: - + inputs: + tag: + description: 'The image tag to deploy' + required: true + type: string jobs: openshift-ci-cd: name: Deploy Backend to EFX @@ -52,6 +56,12 @@ jobs: SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} steps: + - name: Print Workflow Dispatch Inputs and Env Vars + uses: shayki5/print-workflow-dispatch-inputs@v1 + with: + add_to_summary: 'true' + print_env_vars: 'false' + - name: Check for required secrets uses: actions/github-script@v4 with: @@ -95,10 +105,6 @@ jobs: with: ref: ${{ env.BRANCH }} - - 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: @@ -116,8 +122,8 @@ jobs: # Create tag for TEST env from DEV env image oc tag \ - ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} \ - ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} + ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ inputs.tag }} \ + ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ inputs.tag }} # Process and apply deployment template oc process \ @@ -126,7 +132,7 @@ jobs: -p REPO_NAME=${{ env.REPO_NAME }} \ -p BRANCH=${{ env.BRANCH }} \ -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE }} \ - -p TAG=${{ steps.get-latest-tag.outputs.tag }} \ + -p TAG=${{ inputs.tag }} \ -p MIN_REPLICAS=${{ env.MIN_REPLICAS }} \ -p MAX_REPLICAS=${{ env.MAX_REPLICAS }} \ -p MIN_CPU=${{ env.MIN_CPU }} \ diff --git a/.github/workflows/deploy-to-openshift-frontend-efx.yml b/.github/workflows/deploy-to-openshift-frontend-efx.yml index 4eb07cd69..cb5048049 100644 --- a/.github/workflows/deploy-to-openshift-frontend-efx.yml +++ b/.github/workflows/deploy-to-openshift-frontend-efx.yml @@ -43,6 +43,11 @@ env: on: workflow_dispatch: + inputs: + tag: + description: 'The image tag to deploy' + required: true + type: string jobs: openshift-ci-cd: @@ -55,6 +60,12 @@ jobs: SELECTOR: ${{ steps.deploy-and-expose.outputs.selector }} steps: + - name: Print Workflow Dispatch Inputs and Env Vars + uses: shayki5/print-workflow-dispatch-inputs@v1 + with: + add_to_summary: 'true' + print_env_vars: 'false' + - name: Check for required secrets uses: actions/github-script@v4 with: @@ -98,10 +109,6 @@ jobs: with: ref: ${{ env.BRANCH }} - - 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: @@ -119,8 +126,8 @@ jobs: # Create tag for TEST env from DEV env image oc tag \ - ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} \ - ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} + ${{ env.NAMESPACE }}-dev/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ inputs.tag }} \ + ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.IMAGE_NAME }}-${{ env.BRANCH }}:${{ inputs.tag }} # Process and apply deployment template oc process \ @@ -129,7 +136,7 @@ jobs: -p REPO_NAME=${{ env.REPO_NAME }} \ -p BRANCH=${{ env.BRANCH }} \ -p NAMESPACE=${{ env.OPENSHIFT_NAMESPACE }} \ - -p TAG=${{ steps.get-latest-tag.outputs.tag }} \ + -p TAG=${{ inputs.tag }} \ -p MIN_REPLICAS=${{ env.MIN_REPLICAS }} \ -p MAX_REPLICAS=${{ env.MAX_REPLICAS }} \ -p MIN_CPU=${{ env.MIN_CPU }} \ From 9425be2520626339a77efa15ab610b919c3f1392 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Tue, 19 Nov 2024 15:01:18 -0800 Subject: [PATCH 3/5] feat: add deployment specific changes --- .github/workflows/deploy-to-openshift-backend-efx.yml | 8 ++++---- .github/workflows/deploy-to-openshift-frontend-efx.yml | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/deploy-to-openshift-backend-efx.yml b/.github/workflows/deploy-to-openshift-backend-efx.yml index 6c5464163..046baece9 100644 --- a/.github/workflows/deploy-to-openshift-backend-efx.yml +++ b/.github/workflows/deploy-to-openshift-backend-efx.yml @@ -117,7 +117,7 @@ jobs: oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} oc project ${{ env.OPENSHIFT_NAMESPACE }} # Cancel any rollouts in progress - oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "No rollout in progress" # Create tag for TEST env from DEV env image @@ -127,7 +127,7 @@ jobs: # Process and apply deployment template oc process \ - -f tools/openshift/backend.dc.yaml \ + -f tools/openshift/backend.deployment.yaml \ -p APP_NAME=${{ env.APP_NAME }} \ -p REPO_NAME=${{ env.REPO_NAME }} \ -p BRANCH=${{ env.BRANCH }} \ @@ -159,11 +159,11 @@ jobs: ${{ secrets.D365_API_PREFIX }} # Start rollout (if necessary) and follow it - oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful - oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} + oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} - name: ZAP Scan uses: zaproxy/action-full-scan@v0.8.0 diff --git a/.github/workflows/deploy-to-openshift-frontend-efx.yml b/.github/workflows/deploy-to-openshift-frontend-efx.yml index cb5048049..529cd322a 100644 --- a/.github/workflows/deploy-to-openshift-frontend-efx.yml +++ b/.github/workflows/deploy-to-openshift-frontend-efx.yml @@ -121,7 +121,7 @@ jobs: oc login --token=${{ env.OPENSHIFT_TOKEN }} --server=${{ env.OPENSHIFT_SERVER }} oc project ${{ env.OPENSHIFT_NAMESPACE }} # Cancel any rollouts in progress - oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout cancel deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "No rollout in progress" # Create tag for TEST env from DEV env image @@ -131,7 +131,7 @@ jobs: # Process and apply deployment template oc process \ - -f tools/openshift/frontend.dc.yaml \ + -f tools/openshift/frontend.deployment.yaml \ -p APP_NAME=${{ env.APP_NAME }} \ -p REPO_NAME=${{ env.REPO_NAME }} \ -p BRANCH=${{ env.BRANCH }} \ @@ -154,11 +154,11 @@ jobs: | oc apply -f - # Start rollout (if necessary) and follow it - oc rollout latest dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful - oc rollout status dc/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} + oc rollout status deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} - name: ZAP Scan uses: zaproxy/action-full-scan@v0.8.0 From 0f1428c99415061cbd4d48ad9d7fac83944f7e55 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Tue, 19 Nov 2024 15:02:58 -0800 Subject: [PATCH 4/5] fix: restart rollouts, latest doesn't work --- .github/workflows/deploy-to-openshift-backend-prod.yml | 2 +- .github/workflows/deploy-to-openshift-backend-qa.yml | 2 +- .github/workflows/deploy-to-openshift-backend-uat.yml | 2 +- .github/workflows/deploy-to-openshift-frontend-prod.yml | 2 +- .github/workflows/deploy-to-openshift-frontend-qa.yml | 2 +- .github/workflows/deploy-to-openshift-frontend-uat.yml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/deploy-to-openshift-backend-prod.yml b/.github/workflows/deploy-to-openshift-backend-prod.yml index e36cbff4e..de46be042 100644 --- a/.github/workflows/deploy-to-openshift-backend-prod.yml +++ b/.github/workflows/deploy-to-openshift-backend-prod.yml @@ -160,7 +160,7 @@ jobs: ${{ secrets.D365_API_PREFIX }} # Start rollout (if necessary) and follow it - oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful diff --git a/.github/workflows/deploy-to-openshift-backend-qa.yml b/.github/workflows/deploy-to-openshift-backend-qa.yml index d4a449d1c..538f85df2 100644 --- a/.github/workflows/deploy-to-openshift-backend-qa.yml +++ b/.github/workflows/deploy-to-openshift-backend-qa.yml @@ -155,7 +155,7 @@ jobs: ${{ secrets.D365_API_PREFIX }} # Start rollout (if necessary) and follow it - oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful diff --git a/.github/workflows/deploy-to-openshift-backend-uat.yml b/.github/workflows/deploy-to-openshift-backend-uat.yml index 579291eac..507d68000 100644 --- a/.github/workflows/deploy-to-openshift-backend-uat.yml +++ b/.github/workflows/deploy-to-openshift-backend-uat.yml @@ -160,7 +160,7 @@ jobs: ${{ secrets.D365_API_PREFIX }} # Start rollout (if necessary) and follow it - oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }}} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful diff --git a/.github/workflows/deploy-to-openshift-frontend-prod.yml b/.github/workflows/deploy-to-openshift-frontend-prod.yml index 9253a8e52..c9631561a 100644 --- a/.github/workflows/deploy-to-openshift-frontend-prod.yml +++ b/.github/workflows/deploy-to-openshift-frontend-prod.yml @@ -156,7 +156,7 @@ jobs: | oc apply -f - # Start rollout (if necessary) and follow it - oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful diff --git a/.github/workflows/deploy-to-openshift-frontend-qa.yml b/.github/workflows/deploy-to-openshift-frontend-qa.yml index b6fd61311..900cd5ae6 100644 --- a/.github/workflows/deploy-to-openshift-frontend-qa.yml +++ b/.github/workflows/deploy-to-openshift-frontend-qa.yml @@ -149,7 +149,7 @@ jobs: | oc apply -f - # Start rollout (if necessary) and follow it - oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful diff --git a/.github/workflows/deploy-to-openshift-frontend-uat.yml b/.github/workflows/deploy-to-openshift-frontend-uat.yml index 9fe2ec881..23bb05108 100644 --- a/.github/workflows/deploy-to-openshift-frontend-uat.yml +++ b/.github/workflows/deploy-to-openshift-frontend-uat.yml @@ -154,7 +154,7 @@ jobs: | oc apply -f - # Start rollout (if necessary) and follow it - oc rollout latest deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ + oc rollout restart deployment/${{ env.APP_NAME }}-${{ env.IMAGE_NAME }}-${{ env.APP_ENVIRONMENT }} 2> /dev/null \ || true && echo "Rollout in progress" # Get status, returns 0 if rollout is successful From 20ee6f1acd026100a312042986fbc43f6ce2c7e4 Mon Sep 17 00:00:00 2001 From: Trevor Richards Date: Tue, 19 Nov 2024 15:21:50 -0800 Subject: [PATCH 5/5] fix: namespace --- .github/workflows/deploy-to-openshift-backend-efx.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/deploy-to-openshift-backend-efx.yml b/.github/workflows/deploy-to-openshift-backend-efx.yml index 046baece9..2f0a33ef7 100644 --- a/.github/workflows/deploy-to-openshift-backend-efx.yml +++ b/.github/workflows/deploy-to-openshift-backend-efx.yml @@ -7,7 +7,7 @@ env: OPENSHIFT_SERVER: ${{ secrets.OPENSHIFT_SERVER }} OPENSHIFT_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} # EDIT to set the kube context's namespace after login. Leave blank to use your user's default namespace. - OPENSHIFT_NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }}-efx + OPENSHIFT_NAMESPACE: ${{ secrets.CCOF_NAMESPACE_NO_ENV }}-test SPLUNK_TOKEN: ${{ secrets.SPLUNK_TOKEN }}