From df7b0df19a53fa2dc8b9e4b31324e0395bc19c8f Mon Sep 17 00:00:00 2001 From: Wong Yen Hong <89289858+wyhong3103@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:19:43 +0800 Subject: [PATCH] Update test-and-deploy.yml --- .github/workflows/test-and-deploy.yml | 30 +++++++++++++++------------ 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test-and-deploy.yml b/.github/workflows/test-and-deploy.yml index 4d10ebf..0983a24 100644 --- a/.github/workflows/test-and-deploy.yml +++ b/.github/workflows/test-and-deploy.yml @@ -5,9 +5,11 @@ on: push: branches: - main + env: - AWS_REGION: ap-southeast-2 - + AWS_REGION: ap-southeast-2 + ECR_REPOSITORY: sudoku-recognition + jobs: # test: # name: Test @@ -44,17 +46,19 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ env.AWS_REGION }} - - name: Login to Amazon ECR Public - id: login-ecr-public - uses: aws-actions/amazon-ecr-login@v2 - with: - registry-type: public + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 - - name: Build, tag, and push docker image to Amazon ECR Public + - name: Build, tag, and push image to Amazon ECR + id: build-image env: - REGISTRY: ${{ steps.login-ecr-public.outputs.registry }} - REGISTRY_ALIAS: f5b6y5q7 - REPOSITORY: sudoku-recognition + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + IMAGE_TAG: ${{ github.sha }} run: | - docker build -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG . - docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG + # Build a docker container and + # push it to ECR so that it can + # be deployed to ECS. + docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./backend + docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG + echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"