|
16 | 16 | - cron: "0 0 * * 0" # weekly |
17 | 17 |
|
18 | 18 | env: |
19 | | - BUILD_TAG: "build-engine-api:latest" |
| 19 | + BUILD_TAG: "build-engine-api:${{ github.sha }}" |
20 | 20 |
|
21 | 21 | jobs: |
22 | 22 | build: |
|
37 | 37 | run: | |
38 | 38 | echo "COMPOSER_AUTH={\"github-oauth\":{\"github.com\":\""${{ secrets.GITHUB_TOKEN }}\""}}" > local.env |
39 | 39 |
|
| 40 | + - name: Install dependencies |
| 41 | + run: | |
| 42 | + echo "Installing ecs-deploy script..." |
| 43 | + mkdir -p $HOME/.local/bin |
| 44 | + curl -o $HOME/.local/bin/ecs-deploy https://raw.githubusercontent.com/silinternational/ecs-deploy/master/ecs-deploy |
| 45 | + chmod +x $HOME/.local/bin/ecs-deploy |
| 46 | +
|
40 | 47 | - name: Tests |
41 | 48 | run: | |
42 | 49 | make test |
|
54 | 61 | run: | |
55 | 62 | if [[ "${GITHUB_HEAD_REF}" != "" ]]; then BRANCH="${GITHUB_HEAD_REF}"; else BRANCH="${GITHUB_REF_NAME}"; fi |
56 | 63 | case $BRANCH in develop) DOCKER_TAG="staging" ;; master) DOCKER_TAG="production" ;; *) DOCKER_TAG="${BRANCH//\//-}" ;; esac |
| 64 | + case $BRANCH in develop) ECS_CLUSTER="scriptoria-stg";; master) ECS_CLUSTER="scriptoria-prd" ;; *) ECS_CLUSTER="none" ;; esac |
57 | 65 | echo "DockerTag=${DOCKER_TAG}" >> $GITHUB_OUTPUT |
| 66 | + echo "EcsCluster=${ECS_CLUSTER}" >> $GITHUB_OUTPUT |
58 | 67 |
|
59 | 68 | - name: Login to GitHub Container Registry |
60 | 69 | uses: docker/login-action@v2 |
|
84 | 93 |
|
85 | 94 | - name: Push to AWS ECR (SIL) |
86 | 95 | run: | |
87 | | - docker tag ${{ env.BUILD_TAG }} "${{ steps.ecr_sil.outputs.registry }}/appbuilder-buildengine-api:${{ steps.branch.outputs.DockerTag }}" |
| 96 | + docker tag ${{ env.BUILD_TAG }} "${{ steps.ecr_sil.outputs.registry }}/appbuilder-buildengine-api:${{ steps.branch.outputs.DockerTag }}" |
| 97 | + docker tag ${{ env.BUILD_TAG }} "${{ steps.ecr_sil.outputs.registry }}/appbuilder-buildengine-api:${{ github.sha }}" |
88 | 98 | docker push "${{ steps.ecr_sil.outputs.registry }}/appbuilder-buildengine-api:${{ steps.branch.outputs.DockerTag }}" |
| 99 | + docker push "${{ steps.ecr_sil.outputs.registry }}/appbuilder-buildengine-api:${{ github.sha }}" |
| 100 | +
|
| 101 | + - name: Deploy to ECS (SIL) |
| 102 | + if: ${{ steps.branch.outputs.EcsCluster != 'none' }} |
| 103 | + run: | |
| 104 | + echo "Deploying ${{ github.sha }} to ${{ steps.branch.outputs.EcsCluster }}" |
| 105 | + # Deploy to ECS cluster with service name 'build-engine', setting all images to the latest tag |
| 106 | + ecs-deploy -c ${{ steps.branch.outputs.EcsCluster }} -n build-engine -i ignore -to ${{ github.sha }} --max-definitions 20 --timeout 600 |
| 107 | + echo "Deployment initiated successfully." |
89 | 108 |
|
90 | 109 | - name: Clean up older packages |
91 | 110 | uses: actions/delete-package-versions@v4 |
|
0 commit comments