File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11name : Terraform Plan and Apply
22on :
3- workflow_run :
4- workflows : [ "Build and publish image" ]
5- types :
6- - completed
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+
714
815jobs :
916 terraform :
10- if : ${{ github.event.workflow_run.conclusion == 'success' }}
11- environment : ${{ github.event.workflow_run.head_branch == 'main' && 'Production' || 'Sandbox' }}
17+ environment : ${{ github.event.inputs.environment }}
1218 runs-on : ubuntu-latest
1319 # workaround for "context access might be invalid warning"
1420 env :
2329 - name : Get latest tag
2430 id : tag
2531 run : |
26- if [ "${{ github.event.workflow_run.head_branch }}" == "main " ]; then
32+ if [ "${{ github.event.inputs.environment }}" == "Production " ]; then
2733 echo "IMAGE_TAG=$(git describe --tags --abbrev=0)" >> $GITHUB_ENV
2834 else
2935 echo "IMAGE_TAG=dev" >> $GITHUB_ENV
4046 TF_VAR_image_repo=${{ env.IMAGE_REPO }}
4147 EOF
4248 - name : Set sandbox environment variables
43- if : github.event.workflow_run.head_branch == 'SSOTEAM-2579 '
49+ if : github.event.inputs.environment == 'Sandbox '
4450 run : |
4551 cat >> $GITHUB_ENV <<EOF
4652 TF_STATE_BUCKET_NAME=otp-provider-tf-sandbox
9096 EOF
9197
9298 - name : Set production environment variables
93- if : github.event.workflow_run.head_branch == 'main '
99+ if : github.event.inputs.environment == 'Production '
94100 run : |
95101 cat >> $GITHUB_ENV <<EOF
96102 TF_STATE_BUCKET_NAME=otp-provider-tf-production
You can’t perform that action at this time.
0 commit comments