Skip to content

Commit ec1bb80

Browse files
pattonwebzclaude
andcommitted
Check the PR base with gh api, not an unauthenticated ls-remote
This step runs before actions/checkout has configured git credentials, so ls-remote over https has no auth at all. It happens to work here because this repo is public, but it fails with exit 128 against a private one (verified against accessibility-checker-pro with credential helpers disabled) - and the sibling repos share this workflow's shape. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019LoLgW7oFjBPxGea9kiZJ2
1 parent 57268d3 commit ec1bb80

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

.github/workflows/make-pot.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,18 @@ jobs:
9393
9494
# Fail here rather than many minutes later inside create-pull-request,
9595
# which reports a missing base as an opaque 422 from the API.
96+
# `gh api` rather than `git ls-remote`: this step runs before
97+
# actions/checkout has configured any git credentials, so an
98+
# unauthenticated ls-remote cannot see a private repository's branches
99+
# and would fail every single run.
96100
- name: Verify the PR base is a real branch
97101
env:
102+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
98103
BASE: ${{ steps.resolve.outputs.base }}
99-
REPO_URL: ${{ github.server_url }}/${{ github.repository }}
104+
REPO: ${{ github.repository }}
100105
run: |
101106
set -euo pipefail
102-
if [ -z "$(git ls-remote --heads "${REPO_URL}" "refs/heads/${BASE}")" ]; then
107+
if ! gh api "repos/${REPO}/branches/${BASE}" --silent 2>/dev/null; then
103108
echo "::error::'${BASE}' is not a branch in this repository, so a PR cannot target it."
104109
echo "If you built from a tag or SHA, pass the 'base' input to say which branch the PR should go into."
105110
exit 1

0 commit comments

Comments
 (0)