Skip to content

Change Collab host url to be correct in diff files #4

Change Collab host url to be correct in diff files

Change Collab host url to be correct in diff files #4

name: Deploy Matching BE to Amazon ECS
on:
push:
branches: [ "CICD" ]
env:
AWS_REGION: ap-southeast-1 # set this to your preferred AWS region, e.g. us-west-1
ECR_MATCHING_REPOSITORY: peerprep-matching-backend
ECS_MATCHING_SERVICE: Peerprep-Matching-BE
ECS_CLUSTER: PeerPrepDev # set this to your Amazon ECS cluster name
ECS_MATCHING_TASK_DEFINITION: ./backend/matching_backend/task-definition.json
MATCHING_CONTAINER_NAME: Peerprep-Matching-Backend
permissions:
contents: read
jobs:
deploy:
name: Deploy Matching BE
runs-on: 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: Matching service - Build, tag, and push image to Amazon ECR
id: build-matching-service-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
IMAGE_TAG: ${{ github.sha }}
run: |
# Build a docker container and
# push it to ECR so that it can
# be deployed to ECS.
docker build -t $ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG -f ./backend/matching_backend/Dockerfile ./backend/matching_backend
docker push $ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG
echo "image=$ECR_REGISTRY/$ECR_MATCHING_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT
- name: Fill in the new image ID in the Amazon ECS task definition
id: matching-service-task-def
uses: aws-actions/amazon-ecs-render-task-definition@v1
with:
task-definition: ${{ env.ECS_MATCHING_TASK_DEFINITION }}
container-name: ${{ env.MATCHING_CONTAINER_NAME }}
image: ${{ steps.build-matching-service-image.outputs.image }}
- name: Matching service - Deploy Amazon ECS task definition
uses: aws-actions/amazon-ecs-deploy-task-definition@v1
with:
task-definition: ${{ steps.matching-service-task-def.outputs.task-definition }}
service: ${{ env.ECS_MATCHING_SERVICE }}
cluster: ${{ env.ECS_CLUSTER }}
wait-for-service-stability: true