From de70d9a89296afc86e9f9b9659b257161a277c33 Mon Sep 17 00:00:00 2001 From: EndangeredF1sh Date: Wed, 23 Oct 2024 12:31:27 +0800 Subject: [PATCH] fix: ci workflow --- .github/workflows/docker-build-push.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml index 457dcc3..9a72238 100644 --- a/.github/workflows/docker-build-push.yml +++ b/.github/workflows/docker-build-push.yml @@ -30,9 +30,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v3 - - name: Generate build date - id: date - run: echo "BUILD_DATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + - name: Generate build date and short SHA + id: vars + run: | + echo "BUILD_DATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Log in to the Container registry uses: docker/login-action@v2 @@ -48,7 +50,7 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} - type=raw,value=git-${{ github.sha::7 }}-${{ steps.date.outputs.BUILD_DATE }} + type=raw,value=git-${{ steps.vars.outputs.SHORT_SHA }}-${{ steps.vars.outputs.BUILD_DATE }} - name: Build and push Docker image uses: docker/build-push-action@v4