Skip to content

Commit b63506e

Browse files
committed
Fix benchmark PR workflow
1 parent eda1d1d commit b63506e

1 file changed

Lines changed: 18 additions & 5 deletions

File tree

.github/workflows/benchmark.yml

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,32 @@ jobs:
2929
(github.event.workflow_run.conclusion == 'success' &&
3030
github.event.workflow_run.event == 'push')
3131
steps:
32-
- name: Get branch name
32+
- name: Get branch and checkout ref
3333
id: branch
3434
run: |
3535
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
36-
echo "name=${{ github.ref_name }}" >> $GITHUB_OUTPUT
36+
# For manual trigger, use the current branch for both
37+
echo "base_branch=${{ github.ref_name }}" >> $GITHUB_OUTPUT
38+
echo "checkout_ref=${{ github.ref_name }}" >> $GITHUB_OUTPUT
3739
else
38-
echo "name=${{ github.event.workflow_run.head_branch }}" >> $GITHUB_OUTPUT
40+
# For workflow_run trigger, get the head branch
41+
head_branch="${{ github.event.workflow_run.head_branch }}"
42+
# If the head_branch looks like a tag (matches semantic version pattern),
43+
# use main as the base branch for the PR but checkout from main
44+
if [[ "$head_branch" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
45+
echo "Detected tag: $head_branch, using 'main' as base branch"
46+
echo "base_branch=main" >> $GITHUB_OUTPUT
47+
echo "checkout_ref=main" >> $GITHUB_OUTPUT
48+
else
49+
echo "base_branch=$head_branch" >> $GITHUB_OUTPUT
50+
echo "checkout_ref=$head_branch" >> $GITHUB_OUTPUT
51+
fi
3952
fi
4053
- name: Checkout monorepo
4154
uses: actions/checkout@v4
4255
with:
4356
# Checkout the branch, not the commit, to avoid detached HEAD
44-
ref: ${{ steps.branch.outputs.name }}
57+
ref: ${{ steps.branch.outputs.checkout_ref }}
4558
fetch-depth: 2
4659
- name: Determine version to benchmark
4760
id: benchmark_version
@@ -122,5 +135,5 @@ jobs:
122135
123136
Triggered by: ${{ github.event_name }}
124137
branch: benchmark-results-${{ steps.benchmark_version.outputs.value }}
125-
base: ${{ steps.branch.outputs.name }}
138+
base: ${{ steps.branch.outputs.base_branch }}
126139
commit-message: Add benchmark results for version ${{ steps.benchmark_version.outputs.value }}

0 commit comments

Comments
 (0)