11name : Deploy
2+
23on :
34 push :
45 branches :
56 - main
7+ workflow_dispatch :
8+ inputs :
9+ environment :
10+ description : " Select environment to deploy"
11+ required : true
12+ type : choice
13+ options :
14+ - production
15+
616permissions :
717 id-token : write # This is required for requesting tghe JWT
818 contents : read # This is required for actions/checkout
919jobs :
1020 deploy-cube :
1121 runs-on : ubuntu-latest
22+ strategy :
23+ matrix :
24+ include :
25+ - environment : development
26+ ECR_REPO : development-sync-cube-ecr
27+ ECS_CLUSTER : development-sync-cluster
28+ - environment : staging
29+ ECR_REPO : staging-sync-cube-ecr
30+ ECS_CLUSTER : staging-sync-cluster
31+ - environment : production
32+ ECR_REPO : production-sync-cube-ecr
33+ ECS_CLUSTER : production-sync-cluster
34+ environment : ${{ matrix.environment }}
35+
1236 steps :
1337 - name : Checkout repo
1438 uses : actions/checkout@v4
2953 - name : Build, tag, and push cube api docker image to Amazon ECR
3054 env :
3155 REGISTRY : ${{ steps.login-ecr.outputs.registry }}
32- REPOSITORY : prod-sync-cube-ecr
56+ REPOSITORY : ${{ matrix.ECR_REPO }}
3357 IMAGE_TAG : " ${{ github.sha }}"
3458 run : |
3559 docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG -f docker/cube/Dockerfile .
@@ -41,28 +65,28 @@ jobs:
4165 with :
4266 task-definition-family : cube_api
4367 container-name : cube-api
44- image : ${{ steps.login-ecr.outputs.registry }}/prod-sync-cube-ecr :${{ github.sha }}
68+ image : ${{ steps.login-ecr.outputs.registry }}/${{ matrix.ECR_REPO }} :${{ github.sha }}
4569
4670 - name : Update cube-refresh-worker Task Definition with latest image
4771 id : cube-refresh-worker-task-def
4872 uses :
aws-actions/[email protected] 4973 with :
5074 task-definition-family : cube_refresh_worker
5175 container-name : cube-refresh-worker
52- image : ${{ steps.login-ecr.outputs.registry }}/prod-sync-cube-ecr :${{ github.sha }}
76+ image : ${{ steps.login-ecr.outputs.registry }}/${{ matrix.ECR_REPO }} :${{ github.sha }}
5377
5478 - name : Deploy cube-api task definition
5579 uses :
aws-actions/[email protected] 5680 with :
5781 task-definition : ${{ steps.cube-api-task-def.outputs.task-definition }}
5882 service : cube_api
59- cluster : prod-sync-cluster
83+ cluster : ${{ matrix.ECS_CLUSTER }}
6084 wait-for-service-stability : true
6185
6286 - name : Deploy cube-refresh-worker task definition
6387 uses :
aws-actions/[email protected] 6488 with :
6589 task-definition : ${{ steps.cube-refresh-worker-task-def.outputs.task-definition }}
6690 service : cube_refresh_worker
67- cluster : prod-sync-cluster
91+ cluster : ${{ matrix.ECS_CLUSTER }}
6892 wait-for-service-stability : true
0 commit comments