Skip to content

Commit 0db1415

Browse files
committed
Fix branch checking for test-example.yml
1 parent 8afb93e commit 0db1415

File tree

1 file changed

+20
-5
lines changed

1 file changed

+20
-5
lines changed

.github/workflows/test-examples.yml

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,34 @@ jobs:
3636
path: ${{ env.test_repo_path }}
3737

3838
- name: Check for branch ${{ github.head_ref }}
39+
id: check-head-ref
3940
working-directory: ${{ env.test_repo_path }}
4041
if: github.event_name == 'pull_request'
4142
run: |
4243
git remote update
43-
git checkout ${{ github.head_ref }} || echo "${{github.head_ref}} not found, checking base ${{github.base_ref}}"
44+
git checkout ${{ github.head_ref }}
45+
if [ $? -eq 0 ]; then
46+
echo "Using branch ${{github.head_ref}}"
47+
echo "found-branch=1\n" >> $GITHUB_OUTPUT
48+
else
49+
echo "${{github.head_ref}} not found, checking base ${{github.base_ref}}"
50+
echo "found-branch=0\n" >> $GITHUB_OUTPUT
51+
fi
4452
4553
- name: Check for branch ${{ github.base_ref }}
46-
working-directory: ${{ env.test_repo_path }}
47-
if: github.event_name == 'pull_request'
54+
id: check-base-ref
55+
working-directory: ${{ env.test_repo_path }}x
56+
if: github.event_name == 'pull_request' && steps.check-head-ref == 0
4857
run: |
4958
git remote update
50-
git checkout ${{ github.base_ref }} || echo "${{github.base_ref}} not found Falling back to main"
51-
59+
git checkout ${{ github.base_ref }}
60+
if [ $? -eq 0 ]; then
61+
echo "Using branch ${{github.base_ref}}"
62+
echo "found-branch=1\n" >> $GITHUB_OUTPUT
63+
else
64+
|| echo "${{github.base_ref}} not found Falling back to main"
65+
echo "found-branch=0\n" >> $GITHUB_OUTPUT
66+
fi
5267
5368
- name: Set up PDM
5469
uses: pdm-project/setup-pdm@v4

0 commit comments

Comments
 (0)