diff --git a/.github/workflows/cloud-deploy-reusable-app-service-deploy.yml b/.github/workflows/cloud-deploy-reusable-app-service-deploy.yml index 1d942858db9..e91f290e552 100644 --- a/.github/workflows/cloud-deploy-reusable-app-service-deploy.yml +++ b/.github/workflows/cloud-deploy-reusable-app-service-deploy.yml @@ -64,16 +64,34 @@ jobs: working-directory: cloud-infra/terraform/novu/aws run: terraform init + - name: Replace dash with underscore in service_name + id: replace_dash + run: echo "service_name_under=$(echo '${{ inputs.service_name }}' | tr '-' '_')" >> $GITHUB_ENV + - name: Terraform get output working-directory: cloud-infra/terraform/novu/aws + if: inputs.service_name != 'worker' + id: terraform + env: + SERVICE_NAME: ${{ inputs.service_name_under }} + run: | + echo "ecs_container_name=$(terraform output -json ${{ env.SERVICE_NAME }}_ecs_container_name | jq -r .)" >> $GITHUB_ENV + echo "ecs_service=$(terraform output -json ${{ env.SERVICE_NAME }}_ecs_service | jq -r .)" >> $GITHUB_ENV + echo "ecs_cluster=$(terraform output -json ${{ env.SERVICE_NAME }}_ecs_cluster | jq -r .)" >> $GITHUB_ENV + echo "task_name=$(terraform output -json ${{ env.SERVICE_NAME }}_task_name | jq -r .)" >> $GITHUB_ENV + echo "aws_region=$(terraform output -json aws_region | jq -r .)" >> $GITHUB_ENV + + - name: Terraform get output + working-directory: cloud-infra/terraform/novu/aws + if: inputs.service_name == 'worker' id: terraform run: | echo "queue_workers_services=$(terraform output -json queue_workers_services)" >> $GITHUB_OUTPUT echo "ecs_cluster=$(terraform output -json worker_ecs_cluster | jq -r .)" >> $GITHUB_OUTPUT echo "aws_region=$(terraform output -json aws_region | jq -r .)" >> $GITHUB_OUTPUT - deploy_service: + if: inputs.service_name == 'worker' needs: - infrastructure_data runs-on: ubuntu-latest @@ -119,6 +137,49 @@ jobs: cluster: ${{ needs.infrastructure_data.outputs.ecs_cluster }} wait-for-service-stability: true + deploy_service: + if: inputs.service_name != 'worker' + needs: + - infrastructure_data + runs-on: ubuntu-latest + timeout-minutes: 80 + environment: ${{ inputs.environment }} + env: + TF_WORKSPACE: ${{ inputs.terraform_workspace }} + permissions: + contents: read + deployments: write + steps: + - run: echo "Deploying ${{ inputs.service_name }} to ${{ inputs.terraform_workspace }} And Docker Tag ${{ inputs.docker_image }}" + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ env.aws_region }} + + - name: Download task definition + run: | + aws ecs describe-task-definition --task-definition ${{ env.task_name }} \ + --query taskDefinition > task-definition.json + + - name: Render Amazon ECS task definition + id: render-web-container + uses: aws-actions/amazon-ecs-render-task-definition@v1 + with: + task-definition: task-definition.json + container-name: ${{ env.ecs_container_name }} + image: ${{ inputs.docker_image }} + + - name: Deploy to Amazon ECS service + uses: aws-actions/amazon-ecs-deploy-task-definition@v1 + with: + task-definition: ${{ steps.render-web-container.outputs.task-definition }} + service: ${{ env.ecs_service }} + cluster: ${{ env.ecs_cluster }} + wait-for-service-stability: true + post-deploy: needs: - infrastructure_data diff --git a/.github/workflows/cloud-deploy-reusable-embed-deploy.yml b/.github/workflows/cloud-deploy-reusable-embed-deploy.yml index a28a2718ef0..ed8a5497b60 100644 --- a/.github/workflows/cloud-deploy-reusable-embed-deploy.yml +++ b/.github/workflows/cloud-deploy-reusable-embed-deploy.yml @@ -51,7 +51,7 @@ jobs: run: CI='' npm run build:prod - name: Deploy Embed - uses: nwtgck/actions-netlify@v1.2 + uses: nwtgck/actions-netlify@v3.0 with: publish-dir: libs/embed/dist github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cloud-deploy-reusable-web-deploy.yml b/.github/workflows/cloud-deploy-reusable-web-deploy.yml index aecbadb1ac9..a47f21cfb31 100644 --- a/.github/workflows/cloud-deploy-reusable-web-deploy.yml +++ b/.github/workflows/cloud-deploy-reusable-web-deploy.yml @@ -96,7 +96,7 @@ jobs: run: CI='' pnpm build:web - name: Deploy WEB - uses: nwtgck/actions-netlify@v1.2 + uses: nwtgck/actions-netlify@v3.0 with: publish-dir: apps/web/build github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reusable-embed-deploy.yml b/.github/workflows/reusable-embed-deploy.yml index a28a2718ef0..ed8a5497b60 100644 --- a/.github/workflows/reusable-embed-deploy.yml +++ b/.github/workflows/reusable-embed-deploy.yml @@ -51,7 +51,7 @@ jobs: run: CI='' npm run build:prod - name: Deploy Embed - uses: nwtgck/actions-netlify@v1.2 + uses: nwtgck/actions-netlify@v3.0 with: publish-dir: libs/embed/dist github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/reusable-web-deploy.yml b/.github/workflows/reusable-web-deploy.yml index cac2dc959a0..bdf6dd1c759 100644 --- a/.github/workflows/reusable-web-deploy.yml +++ b/.github/workflows/reusable-web-deploy.yml @@ -95,7 +95,7 @@ jobs: run: CI='' pnpm build:web --skip-nx-cache - name: Deploy WEB - uses: nwtgck/actions-netlify@v1.2 + uses: nwtgck/actions-netlify@v3.0 with: publish-dir: apps/web/build github-token: ${{ secrets.GITHUB_TOKEN }}