diff --git a/.github/workflows/auto-fill-pr.yml b/.github/workflows/auto-fill-pr.yml index db3cbf1..d5e69e0 100644 --- a/.github/workflows/auto-fill-pr.yml +++ b/.github/workflows/auto-fill-pr.yml @@ -198,11 +198,30 @@ jobs: const claudeSuccess = '${{ steps.claude.outputs.success }}' === 'true'; const testingSuccess = '${{ steps.testing.outputs.success }}' === 'true'; + // Get PR number - context.payload.pull_request is undefined for workflow_call + let prNumber; + if (context.payload.pull_request) { + prNumber = context.payload.pull_request.number; + } else { + const ref = context.ref.replace('refs/heads/', ''); + const { data: prs } = await github.rest.pulls.list({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + head: `${context.repo.owner}:${ref}` + }); + if (prs.length === 0) { + core.warning('No open PR found for this branch, skipping PR update'); + return; + } + prNumber = prs[0].number; + } + // Get existing PR body const { data: pr } = await github.rest.pulls.get({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.payload.pull_request.number + pull_number: prNumber }); const existingBody = pr.body || ''; @@ -320,7 +339,7 @@ jobs: await github.rest.pulls.update({ owner: context.repo.owner, repo: context.repo.repo, - pull_number: context.payload.pull_request.number, + pull_number: prNumber, body: newBody }); } \ No newline at end of file