Files
pi-review/entrypoint.sh
Markus Hofstetter 28b4b23550 feat: initial pi-review Docker action
Reusable Gitea/GitHub action that runs Pi coding agent for
AI-powered code reviews on pull requests.

- Docker image based on node:24-slim (112 packages)
- Supports built-in providers (zai, anthropic, openai, deepseek, openrouter)
  and custom OpenAI-compatible endpoints
- Generates git diff (excludes lockfiles/generated code by default)
- Posts review as idempotent PR comment (updates existing on re-run)
- Read-only tools only: agent investigates but never modifies code
- 80KB default diff truncation to stay within LLM context windows
- No curl/python3 dependency — uses Node.js for HTTP and JSON
2026-05-18 22:09:46 +02:00

30 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
# ─── Entrypoint for Docker action ────────────────────────────────────────────
# Docker actions receive inputs as INPUT_<NAME> env vars.
# We map them to PI_* vars that review.sh expects, then run the review.
# ──────────────────────────────────────────────────────────────────────────────
# Map Docker action inputs to review.sh env vars
export PI_API_KEY="${INPUT_API_KEY}"
export PI_PROVIDER="${INPUT_PROVIDER:-zai}"
export PI_MODEL="${INPUT_MODEL:-glm-5.1}"
export PI_BASE_URL="${INPUT_BASE_URL:-}"
export PI_TOOLS="${INPUT_TOOLS:-read,grep,find,ls}"
export PI_REVIEW_PROMPT="${INPUT_REVIEW_PROMPT:-}"
export PI_EXCLUDE="${INPUT_EXCLUDE_PATTERNS:-*.lock package-lock.json yarn.lock pnpm-lock.yaml *.min.js *.min.css *.map}"
export PI_MAX_DIFF="${INPUT_MAX_DIFF_BYTES:-80000}"
export PI_TOKEN="${INPUT_TOKEN}"
# The calling repo is mounted at GITHUB_WORKSPACE by both GitHub and Gitea.
# cd into it so git commands work against the right repo.
cd "${GITHUB_WORKSPACE:-/github/workspace}"
echo "Workspace: $(pwd)"
echo "Provider: ${PI_PROVIDER}"
echo "Model: ${PI_MODEL}"
# Run the review
bash /action/scripts/review.sh