Skip to content

Commit 778f36c

Browse files
committed
Fix branch checking for test-example.yml
1 parent f28221b commit 778f36c

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

.github/workflows/test-examples.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,36 @@ jobs:
3535
repository: ${{ matrix.repo.name }}
3636
path: ${{ env.test_repo_path }}
3737

38+
- name: Check for branch ${{ github.head_ref }}
39+
id: check-head-ref
40+
working-directory: ${{ env.test_repo_path }}
41+
if: github.event_name == 'pull_request'
42+
run: |
43+
git remote update
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
52+
53+
- name: Check for branch ${{ github.base_ref }}
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
57+
run: |
58+
git remote update
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
67+
3868
- name: Check for branch ${{ github.head_ref }}
3969
working-directory: ${{ env.test_repo_path }}
4070
if: github.event_name == 'pull_request'

0 commit comments

Comments
 (0)