From b2c1f0704151d71579c7224ec86da57d21327c5a Mon Sep 17 00:00:00 2001 From: Leo Wu Date: Sat, 30 Mar 2024 02:32:25 +0800 Subject: [PATCH] Added timestamp to Docker image tags 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'. --- .github/workflows/docker-push.yaml | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-push.yaml b/.github/workflows/docker-push.yaml index 01fcf66f..9b060684 100644 --- a/.github/workflows/docker-push.yaml +++ b/.github/workflows/docker-push.yaml @@ -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 @@ -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 @@ -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