Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update build rule for nightly image #2421

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions .github/actions/determine-docker-image-tag/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,24 @@ runs:
id: determine_tag_name
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
# 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.
# (At the timing of the start of the image build for tag, vx.x and tag are equal.)
tag=$(echo $GITHUB_REF | sed -e 's:^refs/tags/::') # e.g) v1.7.6
tags="${tag}"
# The following is the priority of tags:
# 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.
# (At the timing of the start of the image build for tag, vx.x and tag are equal.)
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}"
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}"
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}"

commit_hash_tag=${GITHUB_SHA::8}
tags="${tags} ${commit_hash_tag}"
tags="${tags} latest"
commit_hash_tag=${GITHUB_SHA::8}
tags="${tags} ${commit_hash_tag}"
tags="${tags} latest"

elif [[ "${{ github.event_name }}" = "pull_request" || "${{ github.event_name }}" = "pull_request_target" ]]; then
# The following is the priority of tags:
Expand All @@ -80,16 +80,20 @@ runs:
tags="${tags} nightly"

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
tags="${release_branch_tag}"
# 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
tags="${release_branch_tag}"

commit_hash_tag=${GITHUB_SHA::8}
tags="${tags} ${commit_hash_tag}"
tags="${tags} nightly"
commit_hash_tag=${GITHUB_SHA::8}
tags="${tags} ${commit_hash_tag}"
else
tags="unknown"
tag_prefix="unknown/${{ github.event_name }}"
if [[ "$GITHUB_BASE_REF" != "" ]]; then
tags="${tag_prefix}/${GITHUB_BASE_REF}"
else
tags="${tag_prefix}/${GITHUB_SHA::8}"
fi
fi
primary_tag=$(echo ${tags} | awk '{print $1}')

Expand Down
3 changes: 0 additions & 3 deletions .github/actions/docker-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,6 @@ runs:
extra_tags="-t ${IMAGE_NAME}:${PRIMARY_TAG} -t ${ALTER_IMAGE_NAME}:${PRIMARY_TAG}"
else
for tag in ${TAGS}; do
if [[ "${tag}" = "nightly" ]] && (! [[ "$GITHUB_REF" =~ ^refs/heads/main$ ]] || ! [[ "$GITHUB_REF" =~ ^refs/heads/master$ ]]); then
continue
fi
extra_tags="${extra_tags} -t ${IMAGE_NAME}:${tag} -t ${ALTER_IMAGE_NAME}:${tag}"
done
fi
Expand Down
Loading