Skip to content

Commit

Permalink
ci(workflow): branch name extraction for custom format
Browse files Browse the repository at this point in the history
  • Loading branch information
arhamj committed Oct 21, 2024
1 parent ae14a13 commit 4ea5d12
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,25 @@ jobs:
- name: Get short commit hash
id: get-short-hash
run: echo "SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Determine branch name
id: get-branch-name
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV # Source branch of the PR
else
echo "BRANCH_NAME=${{ github.ref_name }}" >> $GITHUB_ENV # Actual branch name for push events
fi
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v6
with:
context: .
file: Dockerfile
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.ref_name }}-${{ env.SHORT_COMMIT_HASH }}
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.BRANCH_NAME }}-${{ env.SHORT_COMMIT_HASH }}
labels: |
version=${{ env.SHORT_COMMIT_HASH }}
branch=${{ github.ref_name }}
branch=${{ env.BRANCH_NAME }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
Expand Down

0 comments on commit 4ea5d12

Please sign in to comment.