Skip to content

Commit

Permalink
Added timestamp to Docker image tags
Browse files Browse the repository at this point in the history
In this revision, we've introduced a change in the way we tag our Docker images. Instead of using the input image tag, we're now tagging them with the current date and time. This is achieved by setting an environment variable with the current datetime which is then used as the tag for both local and ghcr.io images. The timezone has been set to 'Asia/HongKong'.
  • Loading branch information
leokwsw committed Mar 29, 2024
1 parent 85b82ae commit b2c1f07
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/workflows/docker-push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ jobs:
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}

- name: Set current datetime as env variable
env:
TZ: 'Asia/HongKong' # タイムゾーン指定
run: echo "CURRENT_DATETIME=$(date +'%Y-%m-%d-%H%M%S')" >> $GITHUB_ENV

- name: Set up QEMU
uses: docker/setup-qemu-action@v2
Expand Down Expand Up @@ -46,7 +51,7 @@ jobs:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: ${{ github.actor }}/go-chatgpt-api:${{ github.event.inputs.image_tag }}
tags: ${{ github.actor }}/go-chatgpt-api:${{ env.CURRENT_DATETIME }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

Expand All @@ -65,6 +70,6 @@ jobs:
context: .
platforms: ${{ env.PLATFORMS }}
push: true
tags: ghcr.io/${{ github.actor }}/go-chatgpt-api:${{ github.event.inputs.image_tag }}
tags: ghcr.io/${{ github.actor }}/go-chatgpt-api:${{ env.CURRENT_DATETIME }}
cache-from: type=local,src=/tmp/.buildx-cache
cache-to: type=local,dest=/tmp/.buildx-cache,mode=max

0 comments on commit b2c1f07

Please sign in to comment.