Skip to content

Commit 8fa42df

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

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
@@ -21,12 +21,23 @@ jobs:
2121
if: github.repository == 'hibernate/hibernate-validator' && github.event.workflow_run.conclusion != 'cancelled'
2222
runs-on: ubuntu-latest
2323
steps:
24+
# Different branches might have different versions of Develocity, and we want to make sure
25+
# that we publish with the one that we built the scan with in the first place:
26+
- name: Determine the Branch Reference for which the original action was triggered
27+
id: determine_branch_ref
28+
run: |
29+
if [ -n "${{ github.event.workflow_run.pull_requests[0].base.ref }}" ]; then
30+
BRANCH_REF="${{ github.event.workflow_run.pull_requests[0].base.ref }}"
31+
else
32+
BRANCH_REF="${{ github.event.workflow_run.head_branch }}"
33+
fi
34+
echo "original_branch_ref=$BRANCH_REF" >> "$GITHUB_OUTPUT"
2435
# Checkout target branch which has trusted code
2536
- name: Check out target branch
2637
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2
2738
with:
2839
persist-credentials: false
29-
ref: ${{ github.ref }}
40+
ref: ${{ steps.determine_branch_ref.outputs.original_branch_ref }}
3041
- name: Set up Java 21
3142
uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # 4.7.1
3243
with:

0 commit comments

Comments
 (0)