From f1a20eaad26e1f074dc60056225e8b1545cf666d Mon Sep 17 00:00:00 2001 From: Austin Kurtz Date: Thu, 30 Oct 2025 14:31:23 -0700 Subject: [PATCH 1/2] fix: Enable reviewing PR in another repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix for action trying to post reviews to the repo of the triggering workflow instead of the PR’s repo * Use repo_name input for PR checkout * Use separate checkout path to avoid clobbering rules * Ensure PR reviews target repo passed via repo_name --- action.yml | 6 ++++-- templates/guidelines/base.njk | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index 5899402..7994a9b 100644 --- a/action.yml +++ b/action.yml @@ -41,9 +41,11 @@ runs: - name: Checkout PR Head uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0 with: + repository: ${{ inputs.repo_name }} token: ${{ inputs.github_token }} ref: refs/pull/${{ inputs.pull_number }}/head fetch-depth: ${{ inputs.fetch_depth }} + path: pr - name: Prepare Custom Context id: custom_context @@ -51,10 +53,10 @@ runs: run: | if [ -n "$CUSTOM_GUIDELINES" ]; then echo 'context<> $GITHUB_OUTPUT - echo "$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}')" >> $GITHUB_OUTPUT + echo "$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" --arg repo "${{ inputs.repo_name }}" --arg pull_number "${{ inputs.pull_number }}" '{custom_guidelines: $guidelines, repo_name: $repo, pull_number: $pull_number}')" >> $GITHUB_OUTPUT echo 'EOF' >> $GITHUB_OUTPUT else - echo "context={}" >> $GITHUB_OUTPUT + echo "context=$(jq -n --arg repo \"${{ inputs.repo_name }}\" --arg pull_number \"${{ inputs.pull_number }}\" '{repo_name: $repo, pull_number: $pull_number}')" >> $GITHUB_OUTPUT fi env: CUSTOM_GUIDELINES: ${{ inputs.custom_guidelines }} diff --git a/templates/guidelines/base.njk b/templates/guidelines/base.njk index d984e4b..cbb70a8 100644 --- a/templates/guidelines/base.njk +++ b/templates/guidelines/base.njk @@ -11,6 +11,8 @@ - You are currently checked out on the head ref of this pull request. - All changed files for the PR are in the context as CHANGED_FILES - The full set of changes for the PR are in the context as DIFF +- Always target the PR's repository for GitHub operations. Do not use the workflow repository. +- Explicitly set owner/repo for every GitHub call to: {{ custom.repo_name }}; PR number: {{ custom.pull_number }} ### Comment Guidelines: - **HIGH CONFIDENCE ONLY**: Only suggest changes you are highly confident will improve the code From aba1b9a773c76567434080bd6e3094a19cb26844 Mon Sep 17 00:00:00 2001 From: Austin Kurtz Date: Thu, 6 Nov 2025 13:01:50 -0800 Subject: [PATCH 2/2] fix: custom_context output in action + repo info guard in guidelines * Write action context output as single-line JSON * Handle multi-line output when CUSTOM_GUIDELINES are not present --- action.yml | 10 ++++++---- templates/guidelines/base.njk | 5 +++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/action.yml b/action.yml index 7994a9b..c4bf6fd 100644 --- a/action.yml +++ b/action.yml @@ -52,11 +52,13 @@ runs: shell: bash run: | if [ -n "$CUSTOM_GUIDELINES" ]; then - echo 'context<> $GITHUB_OUTPUT - echo "$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" --arg repo "${{ inputs.repo_name }}" --arg pull_number "${{ inputs.pull_number }}" '{custom_guidelines: $guidelines, repo_name: $repo, pull_number: $pull_number}')" >> $GITHUB_OUTPUT - echo 'EOF' >> $GITHUB_OUTPUT + echo 'context<> "$GITHUB_OUTPUT" + jq -n --arg guidelines "$CUSTOM_GUIDELINES" --arg repo "${{ inputs.repo_name }}" --arg pull_number "${{ inputs.pull_number }}" '{custom_guidelines: $guidelines, repo_name: $repo, pull_number: $pull_number}' >> "$GITHUB_OUTPUT" + echo 'EOF' >> "$GITHUB_OUTPUT" else - echo "context=$(jq -n --arg repo \"${{ inputs.repo_name }}\" --arg pull_number \"${{ inputs.pull_number }}\" '{repo_name: $repo, pull_number: $pull_number}')" >> $GITHUB_OUTPUT + echo 'context<> "$GITHUB_OUTPUT" + jq -n --arg repo "${{ inputs.repo_name }}" --arg pull_number "${{ inputs.pull_number }}" '{repo_name: $repo, pull_number: $pull_number}' >> "$GITHUB_OUTPUT" + echo 'EOF' >> "$GITHUB_OUTPUT" fi env: CUSTOM_GUIDELINES: ${{ inputs.custom_guidelines }} diff --git a/templates/guidelines/base.njk b/templates/guidelines/base.njk index cbb70a8..7aab815 100644 --- a/templates/guidelines/base.njk +++ b/templates/guidelines/base.njk @@ -11,8 +11,9 @@ - You are currently checked out on the head ref of this pull request. - All changed files for the PR are in the context as CHANGED_FILES - The full set of changes for the PR are in the context as DIFF -- Always target the PR's repository for GitHub operations. Do not use the workflow repository. -- Explicitly set owner/repo for every GitHub call to: {{ custom.repo_name }}; PR number: {{ custom.pull_number }} +{% if custom.repo_name %} +- Explicitly set owner/repo to '{{ custom.repo_name }}' for GitHub operations +{% endif %} ### Comment Guidelines: - **HIGH CONFIDENCE ONLY**: Only suggest changes you are highly confident will improve the code