Change Collab host url to be correct in diff files #4
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 User 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_USER_REPOSITORY: peerprep-user-backend | |
ECS_USER_SERVICE: Peerprep-User-Backend # set this to your Amazon ECS service name | |
ECS_CLUSTER: PeerPrepDev # set this to your Amazon ECS cluster name | |
ECS_USER_TASK_DEFINITION: ./backend/user_profile_backend/task-definition.json # set this to the path to your Amazon ECS task definition | |
USER_CONTAINER_NAME: peerprep-user-backend # set this to the name of the container in the containerDefinitions section of your task definition | |
permissions: | |
contents: read | |
jobs: | |
deploy: | |
name: Deploy User 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 | |
#repeat everything below this for each service | |
- name: User service - Build, tag, and push image to Amazon ECR | |
id: build-user-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_USER_REPOSITORY:$IMAGE_TAG -f ./backend/user_profile_backend/Dockerfile ./backend/user_profile_backend | |
docker push $ECR_REGISTRY/$ECR_USER_REPOSITORY:$IMAGE_TAG | |
echo "image=$ECR_REGISTRY/$ECR_USER_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT | |
- name: Fill in the new image ID in the Amazon ECS task definition | |
id: user-service-task-def | |
uses: aws-actions/amazon-ecs-render-task-definition@v1 | |
with: | |
task-definition: ${{ env.ECS_USER_TASK_DEFINITION }} | |
container-name: ${{ env.USER_CONTAINER_NAME }} | |
image: ${{ steps.build-user-service-image.outputs.image }} | |
- name: User service - Deploy Amazon ECS task definition | |
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | |
with: | |
task-definition: ${{ steps.user-service-task-def.outputs.task-definition }} | |
service: ${{ env.ECS_USER_SERVICE }} | |
cluster: ${{ env.ECS_CLUSTER }} | |
wait-for-service-stability: true | |