diff --git a/.github/workflows/build_push_ecr.yml b/.github/workflows/build_push_ecr.yml index 0e1ca85..873d0c7 100644 --- a/.github/workflows/build_push_ecr.yml +++ b/.github/workflows/build_push_ecr.yml @@ -3,10 +3,14 @@ name: Build and Push docker image to ECR on: + # push: + # branches: + # - main + # pull_request: push: - branches: - - main - pull_request: + tags: + - 'v[0-9]+.[0-9]+.[0-9]+' + - dev-latest concurrency: group: ${{ github.ref }} @@ -38,11 +42,14 @@ jobs: ECR_REPOSITORY: ${{github.event.repository.name}} # Naming convention: ECR registry name == GITHUB repo name MAIN_BRANCH: main # Images from this branch will be tagged as "latest" run: | + #! Due to we trigger on push.tags GITHUB_REF - is the tag name + GIT_TAG="${GITHUB_REF}" + IMAGE_TAG="${GITHUB_SHA:0:8}" - EXTRA_IMAGE_TAGS="dev-latest" + EXTRA_IMAGE_TAGS=$GIT_TAG - #! Add latest tag only if on MAIN_BRANCH branch - if [[ ${GITHUB_REF} == "refs/heads/${MAIN_BRANCH}" ]]; then + #! Add latest tag only if on named releases tag='v*' + if [[ ${GIT_TAG} == v* ]]; then EXTRA_IMAGE_TAGS="${EXTRA_IMAGE_TAGS};latest" fi