Skip to content

fix: fixing deploy AWS ECS #5

fix: fixing deploy AWS ECS

fix: fixing deploy AWS ECS #5

name: Deploy to AWS ECS
on:
push:
branches:
- main
jobs:
build-and-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Docker
uses: docker/setup-buildx-action@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ vars.AWS_REGION }}
- name: Login to AWS ECR
run: |
aws ecr-public get-login-password --region us-east-1 | docker login --username AWS --password-stdin public.ecr.aws/r8b6j1v6
- name: Build, tag, and push image to Amazon ECR
run: |
cd server
docker build -t ${{ vars.ECR_REPOSITORY }} .
docker tag ${{ vars.ECR_REPOSITORY }}:latest ${{ vars.ECR_REPOSITORY_URI }}:latest
docker push ${{ vars.ECR_REPOSITORY_URI }}:latest
docker push ${{ vars.ECR_REPOSITORY }}
- name: Fill in the new image ID in the ECS task definition
id: latest
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: site-mapper-1-task
container-name: site-mapper-1-container
image: ${{ vars.ECR_REPOSITORY }}:latest
- name: Deploy to ECS
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
service: site-mapper-1-deploy
cluster: site-mapper-1
task-definition: ${{ steps.task-def.outputs.task-definition }}