From 700b3658d6806b1f03b1dda3e5b151899e7fb320 Mon Sep 17 00:00:00 2001 From: George Taylor Date: Fri, 20 Sep 2024 14:53:57 +0100 Subject: [PATCH] Update image-build.yml --- .github/workflows/image-build.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/image-build.yml b/.github/workflows/image-build.yml index 60a1ef9..6de13ca 100644 --- a/.github/workflows/image-build.yml +++ b/.github/workflows/image-build.yml @@ -35,6 +35,16 @@ jobs: echo "SAFE_TAG=$(echo ${{ github.ref_name }} | sed 's/[^a-zA-Z0-9.]/-/g')" >> $GITHUB_OUTPUT fi + - name: Output VERSION_REF + id: output_version_ref + run: | + if "${{ github.event_name }}" == "pull_request"; then + # if on a PR we need to get the current branch name + echo "VERSION_REF=$(echo ${{ github.event.pull_request.head.ref }}" >> $GITHUB_OUTPUT + else + echo "VERSION_REF=$(echo ${{ github.ref_name }}" >> $GITHUB_OUTPUT + fi + - name: Set up Docker Buildx id: setup_buildx uses: docker/setup-buildx-action@v3 @@ -55,7 +65,7 @@ jobs: push: true tags: ghcr.io/ministryofjustice/hmpps-ldap-automation:${{ steps.safe_tag.outputs.SAFE_TAG }} build-args: | - VERSION_REF=${{ steps.BumpVersionAndPushTag.outputs.new_tag }} + VERSION_REF=${{ steps.output_version_ref.outputs.VERSION_REF }} - name: Comment image tag on PR if: github.event_name == 'pull_request'