feat: add service for cronjob and improve scaling using same alarms o… #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Amazon ECS | ||
on: | ||
workflow_run: | ||
workflows: ["Deploy to Amazon ECS"] | ||
types: | ||
- completed | ||
env: | ||
REGISTRY: ghcr.io | ||
AWS_REGION: us-east-1 | ||
IMAGE_NAME: hotosm/tasking-manager-backend | ||
TASK_DEFINITION: tasking-manager-hotosm-staging-fastapi | ||
ECS_CLUSTER: tasking-manager-staging-cluster | ||
ECS_SERVICE: tasking-manager-hotosm-staging-fastapi | ||
CONTAINER_NAME: tasking-manager-hotosm-staging-fastapi | ||
OIDC_ROLE_ARN: arn:aws:iam::670261699094:role/Github-AWS-OIDC | ||
jobs: | ||
deploy: | ||
name: Deploy to ECS | ||
runs-on: ubuntu-latest | ||
environment: production | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: ${{ env.AWS_REGION }} | ||
role-to-assume: ${{ env.OIDC_ROLE_ARN }} | ||
role-session-name: gh-ci-ecs-deploy | ||
- name: Verify AWS identity | ||
run: just aws-whoami | ||
- name: Download task definition | ||
run: | | ||
aws ecs describe-task-definition --task-definition ${{ env.TASK_DEFINITION }} --query taskDefinition > task-definition.json | ||
- name: Task definition rendition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: task-definition.json | ||
container-name: ${{ env.CONTAINER_NAME }} | ||
image: ${{ needs.image-build-and-push.outputs.image_tags }} | ||
- name: Deploy task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v2 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: ${{ env.ECS_SERVICE }} | ||
cluster: ${{ env.ECS_CLUSTER }} | ||
wait-for-service-stability: true |