Skip to content

add github actions

add github actions #1

name: Deploy to Amazon ECS
on:
push:
branches: [ "main" ]
workflow_dispatch:
env:
AWS_REGION: us-east-1
ECR_REPOSITORY: meritpath-backend
ECS_CLUSTER: fargate-cluster
ECS_SERVICE: meritpath-backend-service
permissions:
contents: read
jobs:
deploy:
name: Deploy to ECS
runs-on: ubuntu-latest # Changed from arm64-latest to ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
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: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Build, tag, and push image to Amazon ECR
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
run: |
# Build a docker container for ARM64 and push it to ECR
docker buildx build --platform linux/arm64 \
--tag $ECR_REGISTRY/$ECR_REPOSITORY:latest \
--push ./meritpath-backend
- name: Force new deployment of ECS service
run: |
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment