From 8d10add577348e9439def7e0bce4be593ccc615d Mon Sep 17 00:00:00 2001 From: suyiiyii Date: Sun, 25 Aug 2024 20:00:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(docker-publish):=20=E4=BB=8Emeta=E8=BE=93?= =?UTF-8?q?=E5=87=BA=E4=B8=AD=E6=8F=90=E5=8F=96=E7=89=88=E6=9C=AC=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E9=95=9C=E5=83=8F=E6=A0=87=E7=AD=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker-publish.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 3b0acda..c6c8a29 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -59,6 +59,12 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get current date and commit ID + id: vars + run: | + echo "DATE=$(date +'%y%m%d')" >> $GITHUB_ENV + echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV + # Extract metadata (tags, labels) for Docker # https://github.com/docker/metadata-action - name: Extract Docker metadata @@ -66,6 +72,7 @@ jobs: uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: ${{ env.DATE }}-${{ env.COMMIT }} # Build and push Docker image with Buildx (don't push on PR) # https://github.com/docker/build-push-action @@ -104,11 +111,11 @@ jobs: if: github.event_name == 'push' uses: mikefarah/yq@master with: - cmd: yq eval '.image.tag = "${{ steps.meta.outputs.tags }}"' -i values.yaml + cmd: yq eval '.image.tag = "${{ steps.meta.outputs.version }}"' -i values.yaml - name: Git Auto Commit uses: stefanzweifel/git-auto-commit-action@v5.0.1 with: - commit_message: "Update deployment image to ${{ steps.meta.outputs.tags }}" + commit_message: "Update deployment image to ${{ steps.meta.outputs.version }}" branch: manifest commit_user_name: "github-actions[bot]" commit_user_email: "github-actions[bot]@users.noreply.github.com"