Skip to content

fix: deploy on AWS ECS #10

fix: deploy on AWS ECS

fix: deploy on AWS ECS #10

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 ${{ vars.AWS_REGION }} | 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 site-mapper .
docker tag site-mapper:latest public.ecr.aws/r8b6j1v6/site-mapper:latest
docker push public.ecr.aws/r8b6j1v6/site-mapper:latest
# - 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 }}:${{ github.sha }}
- 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: site-mapper-1-task