Develop #7
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: | |
pull_request: | |
types: [closed] | |
branches: [master] | |
paths: | |
- "frontend/**" | |
env: | |
AWS_REGION: us-east-1 | |
ECS_CLUSTER: medical_assistant_cluster | |
ECS_SERVICE: medical_assistant_frontend | |
ECR_REPOSITORY: 891377268337.dkr.ecr.us-east-1.amazonaws.com/medical_assistant_frontend | |
API_KEY: ${{secrets.API_KEY}} | |
VITE_BACKEND_URL: http://lb-medical-assistant-503996398.us-east-1.elb.amazonaws.com:8000 | |
jobs: | |
build_image_frontend: | |
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 VITE_BACKEND_URL=${{env.VITE_BACKEND_URL}} >> ./frontend/.env | |
docker build -t $ECR_REPOSITORY:$IMAGE_TAG ./frontend | |
docker push $ECR_REPOSITORY:$IMAGE_TAG | |
echo "image=$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
deploy_frontend: | |
runs-on: ubuntu-latest | |
needs: build_image_frontend | |
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 |