Skip to content

Commit

Permalink
build: use short commit id
Browse files Browse the repository at this point in the history
  • Loading branch information
RetricSu committed Jan 20, 2025
1 parent 97f12ff commit 29d6160
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions .github/workflows/pkg.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down

0 comments on commit 29d6160

Please sign in to comment.