-
Notifications
You must be signed in to change notification settings - Fork 13.1k
ci : create git tags for released docker images #16008
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
base: master
Are you sure you want to change the base?
Conversation
0330443
to
182903d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds automatic git tag creation for released Docker images. The purpose is to allow users to easily checkout the corresponding source code for any given Docker image by providing a git tag that matches the Docker image tag.
Key changes:
- Refactors tag determination logic to use a reusable action for generating source tag names
- Adds a step to create and push git tags when Docker images are published
git tag ${{ steps.srctag.outputs.name }} || exit 0 | ||
git push origin ${{ steps.srctag.outputs.name }} || exit 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using || exit 0
to suppress errors masks legitimate failures. Consider using conditional logic to handle expected vs unexpected errors, or at minimum add logging to indicate when tag creation is skipped due to existing tags.
git tag ${{ steps.srctag.outputs.name }} || exit 0 | |
git push origin ${{ steps.srctag.outputs.name }} || exit 0 | |
if git tag "${{ steps.srctag.outputs.name }}"; then | |
echo "Tag '${{ steps.srctag.outputs.name }}' created successfully." | |
else | |
TAG_ERR=$(git tag "${{ steps.srctag.outputs.name }}" 2>&1 || true) | |
if echo "$TAG_ERR" | grep -q "already exists"; then | |
echo "Tag '${{ steps.srctag.outputs.name }}' already exists. Skipping tag creation." | |
else | |
echo "Failed to create tag '${{ steps.srctag.outputs.name }}': $TAG_ERR" | |
exit 1 | |
fi | |
fi | |
if git push origin "${{ steps.srctag.outputs.name }}"; then | |
echo "Tag '${{ steps.srctag.outputs.name }}' pushed successfully." | |
else | |
PUSH_ERR=$(git push origin "${{ steps.srctag.outputs.name }}" 2>&1 || true) | |
if echo "$PUSH_ERR" | grep -q "already exists"; then | |
echo "Tag '${{ steps.srctag.outputs.name }}' already exists on remote. Skipping push." | |
else | |
echo "Failed to push tag '${{ steps.srctag.outputs.name }}': $PUSH_ERR" | |
exit 1 | |
fi | |
fi |
Copilot uses AI. Check for mistakes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is too verbose and it's ok to ignore errors from both git tag
and git push
When releasing a docker image for build number X, we should also create the corresponding git tag. This allows users to easily checkout the corresponding source tree for given docker image.
182903d
to
393e897
Compare
When releasing a docker image for build number X, we should also create the corresponding git tag. This allows users to easily checkout the corresponding source tree for given docker image.