Skip to content

Commit 2cef49a

Browse files
committed
Determine and checkout the original target branch when publishing the build scans
Signed-off-by: marko-bekhta <[email protected]>
1 parent 2209998 commit 2cef49a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

.github/workflows/ci-report.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,23 @@ jobs:
2424
if: github.repository == 'hibernate/hibernate-validator' && github.event.workflow_run.conclusion != 'cancelled'
2525
runs-on: ubuntu-latest
2626
steps:
27+
# Different branches might have different versions of Develocity, and we want to make sure
28+
# that we publish with the one that we built the scan with in the first place:
29+
- name: Determine the Branch Reference for which the original action was triggered
30+
id: determine_branch_ref
31+
run: |
32+
if [ -n "${{ github.event.workflow_run.pull_requests[0].base.ref }}" ]; then
33+
BRANCH_REF="${{ github.event.workflow_run.pull_requests[0].base.ref }}"
34+
else
35+
BRANCH_REF="${{ github.event.workflow_run.head_branch }}"
36+
fi
37+
echo "original_branch_ref=$BRANCH_REF" >> "$GITHUB_OUTPUT"
2738
# Checkout target branch which has trusted code
2839
- name: Check out target branch
2940
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
3041
with:
3142
persist-credentials: false
32-
ref: ${{ github.ref }}
43+
ref: ${{ steps.determine_branch_ref.outputs.original_branch_ref }}
3344
- name: Set up Java 21
3445
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # 4.7.1
3546
with:

0 commit comments

Comments
 (0)