From d27f3889df8cc4caf385e09b5ea102a1106a668e Mon Sep 17 00:00:00 2001 From: Marcelo Gobetti Date: Tue, 3 Mar 2026 21:15:46 -0300 Subject: [PATCH] Use GitHub API to detect default branch for workflow_call git symbolic-ref fails silently (sed exits 0 on empty input, masking the fallback). Use the GitHub API with github.token to reliably get the repo's default branch name instead. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/auto-fill-pr.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-fill-pr.yml b/.github/workflows/auto-fill-pr.yml index bb86695..db3cbf1 100644 --- a/.github/workflows/auto-fill-pr.yml +++ b/.github/workflows/auto-fill-pr.yml @@ -39,12 +39,13 @@ jobs: # Determine base ref (github.base_ref is empty when triggered via workflow_call) BASE_REF="${{ github.base_ref }}" if [ -z "$BASE_REF" ]; then - # Detect default branch from remote - BASE_REF=$(git symbolic-ref --short refs/remotes/origin/HEAD 2>/dev/null | sed 's|origin/||' || echo "main") + # Fetch default branch from GitHub API + BASE_REF=$(curl -s -H "Authorization: Bearer ${{ github.token }}" \ + "https://api.github.com/repos/${{ github.repository }}" | jq -r '.default_branch // "main"') fi # Ensure the base ref is fetched locally - git fetch origin ${BASE_REF} + git fetch origin "${BASE_REF}" # Get the diff (limited to avoid token overflow) DIFF=$(git diff origin/${BASE_REF}...HEAD -- . ':!package-lock.json' ':!yarn.lock' ':!*.min.js' ':!*.min.css' | head -c 30000)