Skip to content

Commit

Permalink
OFMCC-6453 - Add input tag to workflows (#255)
Browse files Browse the repository at this point in the history
* Added tag as input.

* Added step to include inputs in summary.

* Updated qa(test), uat, prod.

* Removed commented out command.
  • Loading branch information
weskubo-cgi authored Oct 29, 2024
1 parent 4080401 commit fe5c2eb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 27 deletions.
20 changes: 13 additions & 7 deletions .github/workflows/deploy-to-openshift-efx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ env:

on:
workflow_dispatch:
inputs:
tag:
description: 'The image tag to deploy'
required: true
type: string

jobs:
openshift-ci-cd:
Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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 \
Expand All @@ -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 }} \
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/deploy-to-openshift-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ env:

on:
workflow_dispatch:
inputs:
tag:
description: 'The image tag to deploy'
required: true
type: string

jobs:
openshift-ci-cd:
Expand Down Expand Up @@ -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:
Expand All @@ -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 \
Expand All @@ -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 }} \
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/deploy-to-openshift-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ env:

on:
workflow_dispatch:
inputs:
tag:
description: 'The image tag to deploy'
required: true
type: string

jobs:
openshift-ci-cd:
Expand Down Expand Up @@ -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:
Expand All @@ -113,17 +114,14 @@ 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 \
-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 TAG=${{ inputs.tag }} \
-p MIN_REPLICAS=${{ env.MIN_REPLICAS }} \
-p MAX_REPLICAS=${{ env.MAX_REPLICAS }} \
-p MIN_CPU=${{ env.MIN_CPU }} \
Expand Down
13 changes: 7 additions & 6 deletions .github/workflows/deploy-to-openshift-uat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ env:

on:
workflow_dispatch:
inputs:
tag:
description: 'The image tag to deploy'
required: true
type: string

jobs:
openshift-ci-cd:
Expand Down Expand Up @@ -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:
Expand All @@ -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 \
Expand All @@ -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 }} \
Expand Down

0 comments on commit fe5c2eb

Please sign in to comment.