diff --git a/.github/workflows/pkg.yml b/.github/workflows/pkg.yml index 59fc9e6..79a96b2 100644 --- a/.github/workflows/pkg.yml +++ b/.github/workflows/pkg.yml @@ -19,7 +19,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - fetch-depth: 0 # get full history to create short-commit-ids + fetch-depth: 0 # Fetch all history for tags + + - name: Get short commit hash + id: short_sha + run: echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT - name: Log in to the Container registry uses: docker/login-action@v2 @@ -35,14 +39,13 @@ jobs: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | ${{ github.ref == 'refs/heads/master' && 'latest' || '' }} - ${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', github.head_ref || github.ref_name, github.sha) }} + ${{ github.ref_type == 'tag' && github.ref_name || format('{0}-{1}', github.head_ref || github.ref_name, steps.short_sha.outputs.SHORT_SHA) }} labels: | org.label-schema.schema-version=1.0 org.label-schema.vcs-url=${{ github.server_url }}/${{ github.repository }} org.label-schema.vcs-ref=${{ github.sha }} org.label-schema.build-date=${{ github.event.push.head_commit.timestamp }} - - name: Build and push Docker image uses: docker/build-push-action@v4 with: