77 required : false
88 DV_BOT_USER :
99 required : false
10- DV_CUSTOMERS :
11- required : true
1210 DV_AWS_ECR_ROLE :
1311 required : false
1412 DV_AWS_REGION :
8684 - uses : ./tmp/github-workflows/.github/actions/get-product-parameters
8785 id : get-parameters
8886 with :
89- dv_customers : ${{ secrets.DV_CUSTOMERS }}
9087 branch_name : ${{ github.ref_name }}
9188 time_zone : ${{ env.TIME_ZONE }}
9289 build-single :
@@ -146,6 +143,26 @@ jobs:
146143 matrix :
147144 customer : ${{ fromJSON(needs.prepare-build.outputs.customers) }}
148145 steps :
146+ - name : determine stage to be deployed to
147+ id : get-parameters
148+ run : |
149+ # Try to split the customer from the format customer:stage
150+ customer="$(echo "$CUSTOMER_FULL" | cut -d ":" -s -f 1)"
151+ stage="$(echo "$CUSTOMER_FULL" | cut -d ":" -s -f 2)"
152+ # If nothing is found, we assume we just got the customer
153+ if [ -z "$customer" ]; then
154+ customer="$CUSTOMER_FULL"
155+ fi
156+ # And will deploy to develop if no stage is defined
157+ if [ -z "$stage" ]; then
158+ echo "customer $CUSTOMER_FULL does not include stage, using develop instead"
159+ stage="develop"
160+ fi
161+ echo "customer=$customer" >> "$GITHUB_OUTPUT"
162+ echo "stage=$stage" >> "$GITHUB_OUTPUT"
163+ env :
164+ CUSTOMER_FULL : ${{ matrix.customer }}
165+ shell : bash
149166 - name : trigger deployment
150167 uses : datavisyn/github-action-trigger-workflow@v1
151168 with :
@@ -155,5 +172,4 @@ jobs:
155172 workflow_file_name : " deploy-app.yml"
156173 ref : ${{ env.WORKFLOW_BRANCH }}
157174 github_user : ${{ secrets.DV_BOT_USER }}
158- # TODO: The deployment is always triggered to develop, do we want to make this configurable?
159- client_payload : ' { "app": "${{ needs.prepare-build.outputs.app }}", "customer": "${{ matrix.customer }}", "stage": "develop", "sub_app": "${{ needs.prepare-build.outputs.sub_app }}", "branch": "${{ needs.prepare-build.outputs.image_tag2 }}" }'
175+ client_payload : ' { "app": "${{ needs.prepare-build.outputs.app }}", "customer": "${{ steps.get-parameters.outputs.customer }}", "stage": "${{ steps.get-parameters.outputs.stage }}", "sub_app": "${{ needs.prepare-build.outputs.sub_app }}", "branch": "${{ needs.prepare-build.outputs.image_tag2 }}" }'
0 commit comments