diff --git a/.github/workflows/public_gateway.yml b/.github/workflows/public_gateway.yml index 0744fa0da..55b0702d6 100644 --- a/.github/workflows/public_gateway.yml +++ b/.github/workflows/public_gateway.yml @@ -18,8 +18,6 @@ jobs: matrix: ${{ steps.set-deployment-matrix.outputs.matrix }} matrixLength: ${{ steps.set-deployment-matrix.outputs.matrixLength }} - # Render task definition doesn't support working directory - # https://github.com/aws-actions/amazon-ecs-render-task-definition/issues/68#issuecomment-881407765 steps: - name: Set Deployment Matrix id: set-deployment-matrix @@ -29,27 +27,30 @@ jobs: [ { "identifier": "public-gateway-staging", - "branch": "develop", + "branch": "fix_deploy_on_staging", "image_tag": "staging", "ecs_service": "public-gateway-staging", - "ecs_cluster": "somleng-switch-staging" + "ecs_cluster": "somleng-switch-staging", + "deploy": "false" + }, { "identifier": "public-gateway", "branch": "master", "image_tag": "latest", "ecs_service": "public-gateway", - "ecs_cluster": "somleng-switch" + "ecs_cluster": "somleng-switch", + "deploy": "true" } ] EOF ) matrix=$(echo $matrixSource | jq --arg branchName "$branchName" 'map(. | select((.branch==$branchName)) )') - echo ::set-output name=matrix::{\"include\":$(echo $matrix)}\" - echo ::set-output name=matrixLength::$(echo $matrix | jq length) + echo "matrix={\"include\":$(echo $matrix)}" >> $GITHUB_OUTPUT + echo "matrixLength=$(echo $matrix | jq length)" >> $GITHUB_OUTPUT - deploy: - name: Deploy + build_packages: + name: Build Packages runs-on: ubuntu-latest needs: - integration_tests @@ -102,9 +103,6 @@ jobs: username: ${{ github.repository_owner }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Set up QEMU - uses: docker/setup-qemu-action@v3 - - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -122,6 +120,26 @@ jobs: ${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} ${{ env.GHCR_REPOSITORY }}:${{ matrix.image_tag }} + deploy: + name: Deploy + runs-on: ubuntu-latest + needs: + - build + - build_packages + + if: needs.build.outputs.matrixLength.deploy + env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + AWS_DEFAULT_REGION: ap-southeast-1 + ECR_REPOSITORY: public.ecr.aws/somleng/public-gateway + OPENSIPS_SCHEDULER_ECR_REPOSITORY: public.ecr.aws/somleng/opensips-scheduler + IMAGE_TAG: ${{ github.sha }} + + strategy: + matrix: ${{fromJson(needs.build.outputs.matrix)}} + + steps: - name: Get current task definition run: | aws ecs describe-task-definition --task-definition "${{ matrix.identifier }}" --query 'taskDefinition' > task-definition.json @@ -130,7 +148,7 @@ jobs: id: render-opensips-scheduler-task-def uses: aws-actions/amazon-ecs-render-task-definition@v1 with: - task-definition: components/gateway/task-definition.json + task-definition: task-definition.json container-name: opensips_scheduler image: ${{ env.OPENSIPS_SCHEDULER_ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} @@ -149,4 +167,3 @@ jobs: service: ${{ matrix.ecs_service }} cluster: ${{ matrix.ecs_cluster }} wait-for-service-stability: true -