Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions mongodb-query-index-check/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,25 @@ runs:
true|false) ;;
*) echo "::error::Invalid request-changes '$REQUEST_CHANGES_INPUT' (must be the literal string 'true' or 'false')."; exit 1 ;;
esac
# Seed the result file so Finalize (runs with `if: always()`) always sees a defined $RESULT_PATH.
echo "RESULT_PATH=${RUNNER_TEMP}/mongo-index-result.txt" >> "$GITHUB_ENV"
printf 'none' > "${RUNNER_TEMP}/mongo-index-result.txt"
# State files live inside the workspace (not RUNNER_TEMP). claude-code-action's Bash sandbox
# only permits reads/writes under $GITHUB_WORKSPACE — paths outside it cost Claude turns on
# retries with native Read/Write before it finds the workaround.
state_dir="${GITHUB_WORKSPACE}/__mongo_index_check"
mkdir -p "$state_dir"
echo "RESULT_PATH=${state_dir}/result.txt" >> "$GITHUB_ENV"
echo "CHANGED_FILES_PATH=${state_dir}/changed-files.json" >> "$GITHUB_ENV"
# Seed the result file so Finalize (runs with `if: always()`) always sees a defined value.
printf 'none' > "${state_dir}/result.txt"

- name: Pre-check PR diff
id: pre-check
uses: actions/github-script@v8
env:
INPUT_PATHS: ${{ inputs.paths }}
INPUT_PATHS_IGNORE: '**/node_modules/**,**/dist/**,**/build/**,**/test/**,**/__tests__/**,**/*.test.*,**/*.spec.*,**/mongo-indexes/**'
OUTPUT_CHANGED_FILES_PATH: ${{ runner.temp }}/mongo-index-changed-files.json
# CHANGED_FILES_PATH was seeded into $GITHUB_ENV by the Validate step. Pass it under the name
# preCheck() reads (OUTPUT_CHANGED_FILES_PATH) so we don't need to mutate process.env in the script.
OUTPUT_CHANGED_FILES_PATH: ${{ env.CHANGED_FILES_PATH }}
Comment on lines +93 to +95
with:
github-token: ${{ inputs.github-token }}
script: |
Expand Down Expand Up @@ -134,7 +142,6 @@ runs:
REPO: ${{ github.repository }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
CHANGED_FILES_PATH: ${{ runner.temp }}/mongo-index-changed-files.json
REQUEST_CHANGES_MODE: ${{ inputs.request-changes }}
run: |
set -euo pipefail
Expand Down Expand Up @@ -164,7 +171,7 @@ runs:
claude_args: >-
--max-turns ${{ inputs.max-turns }}
--model claude-opus-4-7
--allowedTools "mcp__github__pull_request_read,mcp__github__pull_request_review_write,mcp__github__create_pending_pull_request_review,mcp__github__submit_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github_inline_comment__create_inline_comment,Read,Write,Grep,Glob,TodoWrite,Task,Bash(ls:*),Bash(cat:*),Bash(grep:*),Bash(rg:*),Bash(find:*),Bash(test:*),Bash(echo:*),Bash(printf:*),Bash(head:*),Bash(tail:*),Bash(jq:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*),Bash(gh api:*)"
--allowedTools "mcp__github__pull_request_read,mcp__github__pull_request_review_write,mcp__github__create_pending_pull_request_review,mcp__github__submit_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github_inline_comment__create_inline_comment,Read,Write,Grep,Glob,TodoWrite,Task,Bash(ls:*),Bash(cat:*),Bash(grep:*),Bash(rg:*),Bash(find:*),Bash(test:*),Bash(echo:*),Bash(printf:*),Bash(head:*),Bash(tail:*),Bash(wc:*),Bash(awk:*),Bash(sed:*),Bash(sort:*),Bash(jq:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr review:*),Bash(gh api:*)"

- name: Finalize review result
id: finalize
Expand Down
12 changes: 11 additions & 1 deletion mongodb-query-index-check/prompts/review.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,17 @@ When submitting, include a brief summary body — at most 4 short bullets coveri

### 4. Persist the result

After submitting the review (or after deciding no review is needed), write the maximum severity to `$RESULT_PATH` as a single lowercase word with **no whitespace and no newline**. Examples: `none`, `low`, `medium`, `high`, `critical`. Use either `Write` or `printf "%s" <word> > $RESULT_PATH`.
After submitting the review (or after deciding no review is needed), write the maximum severity to `$RESULT_PATH` as a single lowercase word with **no whitespace and no newline**. Examples: `none`, `low`, `medium`, `high`, `critical`. **Use the `Write` tool** — bash output redirection (`>`, `>>`) is blocked by the sandbox even for paths inside the workspace, so `printf > $RESULT_PATH` will fail.

## Bash sandbox notes

The bash sandbox imposes a few constraints worth knowing up-front so you don't waste turns on retries:

- **Output redirection (`>`, `>>`, `tee` to a file) is blocked**, even for paths inside the workspace. Use the `Write` tool when you need to create a file. Pipes (`|`) between allowed commands are fine.
- **Chained commands (`&&`, `;`) are rejected** as "multiple operations". Issue one command per `Bash` call.
- **Paths outside `$GITHUB_WORKSPACE` are blocked** for bash read/write. The state paths you've been given (`$CHANGED_FILES_PATH`, `$RESULT_PATH`, `$MONGO_INDEXES_DIR`) all live inside the workspace, so use them as-is. The `Read` and `Write` tools work for any path.

Prefer the native `Read`, `Write`, `Grep`, `Glob` tools over bash equivalents wherever you can — they're free of these constraints.

## Hard constraints

Expand Down
Loading