From 0b6ecba5c4c4bd80c651f383ec18a74957012910 Mon Sep 17 00:00:00 2001 From: Sotatek-TuLe2 Date: Fri, 19 Jul 2024 09:54:03 +0700 Subject: [PATCH] edit image tagging rule --- .github/workflows/prod-build.yaml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/prod-build.yaml b/.github/workflows/prod-build.yaml index 4c2b7cf..bdf120b 100644 --- a/.github/workflows/prod-build.yaml +++ b/.github/workflows/prod-build.yaml @@ -1,7 +1,7 @@ name: kaia-websites-api build image workflow for PROD env on: push: - branches: ["main","modify-cicd"] + branches: ["main", "modify-cicd"] jobs: deploy: @@ -25,13 +25,15 @@ jobs: uses: aws-actions/amazon-ecr-login@v1 id: login-ecr + - name: Extract commit hash + id: vars + run: echo "::set-output name=hash::$(git rev-parse --short HEAD)" + - name: Build, tag, and push image API to Amazon ECR env: ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }} - IMAGE_TAG: ${{ github.ref_name }} + IMAGE_TAG: ${{ steps.vars.outputs.hash }} run: | docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG . docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - -