File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- name : Build and publish image
1+ name : Build and Publish Docker Image
22
33on :
44 push :
Original file line number Diff line number Diff line change 11name : Terraform Plan and Apply
22on :
3- workflow_dispatch :
4- inputs :
5- environment :
6- description : ' The target environment for deployment'
7- required : true
8- default : ' Sandbox'
9- type : choice
10- options :
11- - Sandbox
12- - Production
13-
3+ workflow_run :
4+ workflows : [ "Build and publish image" ]
5+ types :
6+ - completed
7+ branches :
8+ - ' SSOTEAM-2579'
9+ - ' dev'
10+ - ' main'
1411
1512jobs :
1613 terraform :
17- environment : ${{ github.event.inputs.environment }}
14+ if : ${{ github.event.workflow_run.conclusion == 'success' }}
15+ environment : ${{ github.event.workflow_run.head_branch == 'main' && 'Production' || 'Sandbox' }}
1816 runs-on : ubuntu-latest
1917 # workaround for "context access might be invalid warning"
2018 env :
2927 - name : Get latest tag
3028 id : tag
3129 run : |
32- if [ "${{ github.event.inputs.environment }}" == "Production " ]; then
30+ if [ "${{ github.event.workflow_run.head_branch }}" == "main " ]; then
3331 echo "IMAGE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
3432 else
3533 echo "IMAGE_TAG=dev" >> $GITHUB_ENV
4644 TF_VAR_image_repo=${{ env.IMAGE_REPO }}
4745 EOF
4846 - name : Set sandbox environment variables
49- if : github.event.inputs.environment == 'Sandbox '
47+ if : github.event.workflow_run.head_branch == 'SSOTEAM-2579 '
5048 run : |
5149 cat >> $GITHUB_ENV <<EOF
5250 TF_STATE_BUCKET_NAME=otp-provider-tf-sandbox
9694 EOF
9795
9896 - name : Set production environment variables
99- if : github.event.inputs.environment == 'Production '
97+ if : github.event.workflow_run.head_branch == 'main '
10098 run : |
10199 cat >> $GITHUB_ENV <<EOF
102100 TF_STATE_BUCKET_NAME=otp-provider-tf-production
You can’t perform that action at this time.
0 commit comments