From 8a77a5d6ce0cd08c6720c94527b02ca5c811b8e6 Mon Sep 17 00:00:00 2001 From: Hiroto Funakoshi Date: Tue, 27 Feb 2024 17:44:51 +0900 Subject: [PATCH] Fix output settings to determine-docker-image-tag action and release branch build tag name (#2423) * fix: add outut settings for action Signed-off-by: hlts2 * fix: tag name for release branch build Signed-off-by: hlts2 * fix: refactor Signed-off-by: hlts2 --------- Signed-off-by: hlts2 --- .../determine-docker-image-tag/action.yaml | 30 +++++++++++-------- .github/actions/docker-build/action.yaml | 1 - 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/.github/actions/determine-docker-image-tag/action.yaml b/.github/actions/determine-docker-image-tag/action.yaml index 9354f38698..0aa55f2373 100644 --- a/.github/actions/determine-docker-image-tag/action.yaml +++ b/.github/actions/determine-docker-image-tag/action.yaml @@ -22,6 +22,9 @@ outputs: PRIMARY_TAG: description: "highest priority docker image tag in tag list" value: ${{ steps.determine_tag_name.outputs.PRIMARY_TAG }} + SECONDARY_TAGS: + description: "List of tags excluding the first one" + value: ${{ steps.determine_tag_name.outputs.SECONDARY_TAGS }} runs: using: "composite" steps: @@ -39,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. @@ -47,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. @@ -81,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="$(echo $GITHUB_REF | sed -e 's:^refs/heads/release/: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