Skip to content

Commit a248ec7

Browse files
committed
Fix branch name for pull_request events
For pull_request events, github.ref_name resolves to the merge ref (e.g. "21/merge") instead of a real branch name. This caused sphinx-versioned to fail with: error: pathspec '21/merge' did not match any file(s) Use github.base_ref (the PR target branch) for pull_request events, falling back to github.ref_name for push events.
1 parent 217d12b commit a248ec7

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

.github/workflows/python_sphinx_docs.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ jobs:
7070
7171
# Dynamically determine which branches to build documentation for
7272
# This allows the workflow to work on forks that may not have all release branches
73-
BRANCHES=$(../scripts/get_doc_branches.sh "${{ github.ref_name }}")
73+
# For pull_request events, github.ref_name is the merge ref (e.g. "21/merge"),
74+
# not a real branch. Use github.base_ref (the PR target branch, e.g. "master")
75+
# instead, falling back to github.ref_name for push/dispatch events where
76+
# github.base_ref is empty.
77+
BRANCHES=$(../scripts/get_doc_branches.sh "${{ github.base_ref || github.ref_name }}")
7478
echo "Building documentation for branches: $BRANCHES"
7579
poetry run sphinx-versioned -m master -b "$BRANCHES" --force --git-root ../../
7680
- name: Copy documentation to gh-pages

0 commit comments

Comments
 (0)