From fa6e8ef37ac805981b53691414be12928fb82d22 Mon Sep 17 00:00:00 2001 From: Marcelo Gobetti Date: Tue, 3 Mar 2026 20:41:03 -0300 Subject: [PATCH] Fix empty base_ref when workflow triggered via workflow_call github.base_ref is only set for pull_request events, causing 'origin/...HEAD' when called via workflow_call. Fall back to 'main'. Co-Authored-By: Claude Sonnet 4.6 --- .github/workflows/auto-fill-pr.yml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/.github/workflows/auto-fill-pr.yml b/.github/workflows/auto-fill-pr.yml index 0c2cb96..0167afd 100644 --- a/.github/workflows/auto-fill-pr.yml +++ b/.github/workflows/auto-fill-pr.yml @@ -36,12 +36,18 @@ jobs: - name: Get diff for Claude id: diff run: | + # Determine base ref (github.base_ref is empty when triggered via workflow_call) + BASE_REF="${{ github.base_ref }}" + if [ -z "$BASE_REF" ]; then + BASE_REF="main" + fi + # Get the diff (limited to avoid token overflow) - DIFF=$(git diff origin/${{ github.base_ref }}...HEAD -- . ':!package-lock.json' ':!yarn.lock' ':!*.min.js' ':!*.min.css' | head -c 30000) + DIFF=$(git diff origin/${BASE_REF}...HEAD -- . ':!package-lock.json' ':!yarn.lock' ':!*.min.js' ':!*.min.css' | head -c 30000) # Get file list - FILES=$(git diff --name-only origin/${{ github.base_ref }}...HEAD) - STATS=$(git diff --shortstat origin/${{ github.base_ref }}...HEAD) + FILES=$(git diff --name-only origin/${BASE_REF}...HEAD) + STATS=$(git diff --shortstat origin/${BASE_REF}...HEAD) FILE_COUNT=$(echo "$FILES" | wc -l) # Write to files to avoid escaping issues