-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add date-based docker image tag #71
Conversation
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.
The changes look good, but I have some minor remarks.
Instead of the modifying the environment, you could also use GitHub's output feature if you want, which is a bit more verbose:
- name: determine date-time-based tag
id: docker-img-tag
run: |
echo "::set-output name=tag::$(date +%Y-%m-%dT%H-%M)"
tags: |
ghcr.io/${{github.repository}}:latest
ghcr.io/${{github.repository}}:${{steps.docker-img-tag.outputs.tag}}
.github/workflows/build-publish.yml
Outdated
@@ -27,12 +27,17 @@ jobs: | |||
username: ${{ github.actor }} | |||
password: ${{ github.token }} | |||
|
|||
- name: set date-based tag | |||
run: | | |||
echo "DATE_TAG=$(date +%Y-%m-%dT%H-%M)" >> $GITHUB_ENV |
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.
Given that the tag contains hours and minutes, let's call the variable DATE_TIME_TAG
.
Although I couldn't provoke a collision with Bash-builtin syntax, I'd say it's better to be on the safe side and put the format string into single quotes.
echo "DATE_TAG=$(date +%Y-%m-%dT%H-%M)" >> $GITHUB_ENV | |
echo "DATE_TIME_TAG=$(date '+%Y-%m-%dT%H-%M')" >> $GITHUB_ENV |
.github/workflows/build-publish.yml
Outdated
- name: build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository }}:latest | ||
ghcr.io/${{ github.repository }}:${{ env.DATE_TAG }} |
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.
ghcr.io/${{ github.repository }}:${{ env.DATE_TAG }} | |
ghcr.io/${{ github.repository }}:${{ env.DATE_TIME_TAG }} |
This PR introduces date-based image tags (
Y-%m-%dT%H-%M
) for docker images built on the main branch.