Skip to content

Commit

Permalink
fix: ECS Deployment update
Browse files Browse the repository at this point in the history
  • Loading branch information
AliaksandrRyzhou committed Jul 5, 2024
1 parent e7f7536 commit d083279
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 5 deletions.
63 changes: 62 additions & 1 deletion .github/workflows/cloud-deploy-reusable-app-service-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cloud-deploy-reusable-embed-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/cloud-deploy-reusable-web-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-embed-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/reusable-web-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down

0 comments on commit d083279

Please sign in to comment.