Skip to content

Merge pull request #23 from Sebastian-411/develop #16

Merge pull request #23 from Sebastian-411/develop

Merge pull request #23 from Sebastian-411/develop #16

Workflow file for this run

name: Deploy to Amazon ECS
on:
push:
branches:
- master
env:
AWS_REGION: us-east-1
ECS_CLUSTER: medical_assistant_cluster
ECS_SERVICE: medical_assistant_backend
ECR_REPOSITORY: 891377268337.dkr.ecr.us-east-1.amazonaws.com/medical_assistant_backend
API_KEY: ${{secrets.API_KEY}}
jobs:
build_image_backend:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@0e613a0980cbf65ed5b322eb7a1e075d28913a83
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@62f4f872db3836360b72999f4b87f1ff13310f3a
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
IMAGE_TAG: lastest
run: |
echo API_KEY=${{env.API_KEY}} >> ./backend/.env
docker build -t $ECR_REPOSITORY:$IMAGE_TAG ./backend
docker push $ECR_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Checkout repository
uses: actions/checkout@v2
deploy_backend:
runs-on: ubuntu-latest
needs: build_image_backend
steps:
- 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: Deploy to ECS
run: |
aws ecs update-service --cluster ${{ env.ECS_CLUSTER }} --service ${{ env.ECS_SERVICE }} --force-new-deployment