diff --git a/action.yml b/action.yml index 5899402..c4bf6fd 100644 --- a/action.yml +++ b/action.yml @@ -41,20 +41,24 @@ 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 shell: bash run: | if [ -n "$CUSTOM_GUIDELINES" ]; then - echo 'context<> $GITHUB_OUTPUT - echo "$(jq -n --arg guidelines "$CUSTOM_GUIDELINES" '{custom_guidelines: $guidelines}')" >> $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={}" >> $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 d984e4b..7aab815 100644 --- a/templates/guidelines/base.njk +++ b/templates/guidelines/base.njk @@ -11,6 +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 +{% 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