From fe5c2eb949b7c49e247bb7209a6bbdf8f4a86e5f Mon Sep 17 00:00:00 2001 From: weskubo-cgi <80127167+weskubo-cgi@users.noreply.github.com> Date: Tue, 29 Oct 2024 13:04:11 -0700 Subject: [PATCH] OFMCC-6453 - Add input tag to workflows (#255) * Added tag as input. * Added step to include inputs in summary. * Updated qa(test), uat, prod. * Removed commented out command. --- .github/workflows/deploy-to-openshift-efx.yml | 20 ++++++++++++------- .../workflows/deploy-to-openshift-prod.yml | 13 ++++++------ .../workflows/deploy-to-openshift-test.yml | 14 ++++++------- .github/workflows/deploy-to-openshift-uat.yml | 13 ++++++------ 4 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.github/workflows/deploy-to-openshift-efx.yml b/.github/workflows/deploy-to-openshift-efx.yml index 5635bc1..5565e56 100644 --- a/.github/workflows/deploy-to-openshift-efx.yml +++ b/.github/workflows/deploy-to-openshift-efx.yml @@ -40,6 +40,11 @@ env: on: workflow_dispatch: + inputs: + tag: + description: 'The image tag to deploy' + required: true + type: string jobs: openshift-ci-cd: @@ -52,6 +57,11 @@ 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@v6 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: @@ -117,8 +123,8 @@ jobs: # Create the image stream if it doesn't exist oc create imagestream ${{ env.IMAGE_NAME }} 2> /dev/null || true && echo "D365 API image stream in place" - # Create tag for UAT env from DEV env image - oc tag ${{ env.NAMESPACE }}-dev/${{ env.IMAGE_NAME }}:${{ steps.get-latest-tag.outputs.tag }} ${{ env.NAMESPACE }}-test/${{ env.IMAGE_NAME }}:${{ steps.get-latest-tag.outputs.tag }} + # Create tag for EFX env from DEV env image + oc tag ${{ env.NAMESPACE }}-dev/${{ env.IMAGE_NAME }}:${{ inputs.tag }} ${{ env.NAMESPACE }}-test/${{ env.IMAGE_NAME }}:${{ inputs.tag }} # Process and apply deployment template oc process \ @@ -127,7 +133,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-prod.yml b/.github/workflows/deploy-to-openshift-prod.yml index 786880b..36f6428 100644 --- a/.github/workflows/deploy-to-openshift-prod.yml +++ b/.github/workflows/deploy-to-openshift-prod.yml @@ -40,6 +40,11 @@ env: on: workflow_dispatch: + inputs: + tag: + description: 'The image tag to deploy' + required: true + type: string jobs: openshift-ci-cd: @@ -95,10 +100,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: @@ -118,7 +119,7 @@ jobs: oc create imagestream ${{ env.IMAGE_NAME }} 2> /dev/null || true && echo "D365 API image stream in place" # Create tag for PROD env from DEV env image - oc tag ${{ env.NAMESPACE }}-dev/${{ env.IMAGE_NAME }}:${{ steps.get-latest-tag.outputs.tag }} ${{ env.NAMESPACE }}-prod/${{ env.IMAGE_NAME }}:${{ steps.get-latest-tag.outputs.tag }} + oc tag ${{ env.NAMESPACE }}-dev/${{ env.IMAGE_NAME }}:${{ inputs.tag }} ${{ env.NAMESPACE }}-prod/${{ env.IMAGE_NAME }}:${{ inputs.tag }} # Process and apply deployment template oc process \ @@ -127,7 +128,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-test.yml b/.github/workflows/deploy-to-openshift-test.yml index 536f66b..9dd2693 100644 --- a/.github/workflows/deploy-to-openshift-test.yml +++ b/.github/workflows/deploy-to-openshift-test.yml @@ -39,6 +39,11 @@ env: on: workflow_dispatch: + inputs: + tag: + description: 'The image tag to deploy' + required: true + type: string jobs: openshift-ci-cd: @@ -94,10 +99,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: @@ -113,9 +114,6 @@ jobs: oc rollout cancel dc/${{ env.APP_NAME }}-${{ env.APP_NAME_BACKEND }} 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.APP_NAME_BACKEND }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} ${{ env.NAMESPACE }}-test/${{ env.REPO_NAME }}-${{ env.APP_NAME_BACKEND }}-${{ env.BRANCH }}:${{ steps.get-latest-tag.outputs.tag }} - # Process and apply deployment template oc process \ -f tools/openshift/d365api.dc.yaml \ @@ -123,7 +121,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-uat.yml b/.github/workflows/deploy-to-openshift-uat.yml index 9732b0d..097cf4c 100644 --- a/.github/workflows/deploy-to-openshift-uat.yml +++ b/.github/workflows/deploy-to-openshift-uat.yml @@ -40,6 +40,11 @@ env: on: workflow_dispatch: + inputs: + tag: + description: 'The image tag to deploy' + required: true + type: string jobs: openshift-ci-cd: @@ -95,10 +100,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: @@ -118,7 +119,7 @@ jobs: oc create imagestream ${{ env.IMAGE_NAME }} 2> /dev/null || true && echo "D365 API image stream in place" # Create tag for UAT env from DEV env image - oc tag ${{ env.NAMESPACE }}-dev/${{ env.IMAGE_NAME }}:${{ steps.get-latest-tag.outputs.tag }} ${{ env.NAMESPACE }}-test/${{ env.IMAGE_NAME }}:${{ steps.get-latest-tag.outputs.tag }} + oc tag ${{ env.NAMESPACE }}-dev/${{ env.IMAGE_NAME }}:${{ inputs.tag }} ${{ env.NAMESPACE }}-test/${{ env.IMAGE_NAME }}:${{ inputs.tag }} # Process and apply deployment template oc process \ @@ -127,7 +128,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 }} \