From 250915176779e0a98ef72a9ad9a455fdf353f21c Mon Sep 17 00:00:00 2001 From: hlts2 Date: Tue, 27 Feb 2024 15:18:24 +0900 Subject: [PATCH] fix: tag name for release branch build Signed-off-by: hlts2 --- .../determine-docker-image-tag/action.yaml | 27 ++++++++++--------- .github/actions/docker-build/action.yaml | 1 - 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/actions/determine-docker-image-tag/action.yaml b/.github/actions/determine-docker-image-tag/action.yaml index 06725a9a4a..4e30d4c14d 100644 --- a/.github/actions/determine-docker-image-tag/action.yaml +++ b/.github/actions/determine-docker-image-tag/action.yaml @@ -42,7 +42,7 @@ runs: run: | if [[ "$GITHUB_REF" =~ ^refs/tags/.* ]]; then # The following is the priority of tags: - # tag -> release/vx.x tag (release branch build tag) -> commit hash tag -> vx.x -> latest tag + # tag -> release-vx.x tag (release branch build tag) -> commit hash tag -> vx.x -> latest tag # When a tag is created, the image build for the tag may not be finished. # In that case, the CI container will use the tag for the release branch. # At the timing of the creation of the tag, the vx.x points to the previous version, so the priority is lowered. @@ -50,26 +50,27 @@ runs: tag=$(echo $GITHUB_REF | sed -e 's:^refs/tags/::') # e.g) v1.7.6 tags="${tag}" - release_branch_tag="release/${major_minor_tag}" # e.g) release/v1.7 - tags="${tags} ${release_branch_tag}" - major_minor_tag="$(echo "${tag}" | sed -E 's/^v?([0-9]+\.[0-9]+).*$/v\1/')" # e.g) v.1.7 - tags="${tags} ${major_minor_tag}" + release_branch_tag="release-${major_minor_tag}" # e.g) release-v1.7 + + tags="${tags} ${release_branch_tag}" commit_hash_tag=${GITHUB_SHA::8} tags="${tags} ${commit_hash_tag}" + tags="${tags} ${major_minor_tag}" tags="${tags} latest" elif [[ "${{ github.event_name }}" = "pull_request" || "${{ github.event_name }}" = "pull_request_target" ]]; then # The following is the priority of tags: - # pr-xxx tag (PR build tag) -> release/vx.x tag (release branch tag) or nightly tag + # pr-xxx tag (PR build tag) -> release-vx.x tag (release branch tag) or nightly tag pr_num=$(cat $GITHUB_EVENT_PATH | jq -r ".number") tags="pr-${pr_num}" - # For pull request to the release branch, use the release branch latest tag as the default tag (release/vx.x). + # For pull request to the release branch, use the release branch latest tag as the default tag (release-vx.x). # This is only set if the event that triggers the workflow execution is pull_request or pull_request_target. if [[ "$GITHUB_BASE_REF" =~ ^release/v([0-9]+)\.([0-9]+)$ ]]; then - tags="${tags} $(echo "$GITHUB_BASE_REF")" + release_branch_tag="$(echo "$GITHUB_BASE_REF" | sed 's:/:-:g')" + tags="${tags} ${release_branch_tag}" else # Currently, it is assumed to be nightly. # However, further conditions will be added in the future if they cause inconvenience. @@ -84,18 +85,18 @@ runs: elif [[ "$GITHUB_REF" =~ ^refs/heads/release/v([0-9]+)\.([0-9]+)$ ]]; then # The following is the priority of tags: - # release/vx.x tag (release branch build tag) -> commit hash tag -> nightly tag - release_branch_tag=$(echo $GITHUB_REF | sed -e 's:^refs/heads/::') # e.g) release/v1.7 + # release-vx.x tag (release branch build tag) -> commit hash tag + release_branch_tag="release-$(echo $GITHUB_REF | sed -e 's:^refs/heads/release/::')" # e.g) release-v1.7 tags="${release_branch_tag}" commit_hash_tag=${GITHUB_SHA::8} tags="${tags} ${commit_hash_tag}" else - tag_prefix="unknown/${{ github.event_name }}" + tag_prefix="unknown-${{ github.event_name }}" if [[ "$GITHUB_BASE_REF" != "" ]]; then - tags="${tag_prefix}/${GITHUB_BASE_REF}" + tags="${tag_prefix}-${GITHUB_BASE_REF}" else - tags="${tag_prefix}/${GITHUB_SHA::8}" + tags="${tag_prefix}-${GITHUB_SHA::8}" fi fi primary_tag=$(echo ${tags} | awk '{print $1}') diff --git a/.github/actions/docker-build/action.yaml b/.github/actions/docker-build/action.yaml index a688286cb0..5c8c20ffbe 100644 --- a/.github/actions/docker-build/action.yaml +++ b/.github/actions/docker-build/action.yaml @@ -104,7 +104,6 @@ runs: env: IMAGE_NAME: ${{ steps.image_name.outputs.IMAGE_NAME }} ALTER_IMAGE_NAME: ${{ steps.image_name.outputs.ALTER_IMAGE_NAME }} - PRIMARY_TAG: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} SECONDARY_TAGS: ${{ steps.determine_tag_name.outputs.SECONDARY_TAGS }} - name: Build and Push shell: bash