name: Gemini Review on: pull_request: types: [opened, synchronize] # Runs on new PRs and updates jobs: Gemini: runs-on: local steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 ref: ${{ github.ref }} fetch-tags: true - name: Check if last commit is from Renovate Bot id: check-renovate run: | AUTHOR=$(git log -1 --pretty=format:'%an') echo "Author is $AUTHOR" echo "author=$AUTHOR" >> "$GITHUB_OUTPUT" - name: Set Tea Version id: tea_version run: echo "version=0.9.2" >> $GITHUB_OUTPUT # Check for the latest version - name: Download Tea CLI run: | TEA_VERSION=$(echo "${{ steps.tea_version.outputs.version }}") wget "https://gitea.com/gitea/tea/releases/download/v${TEA_VERSION}/tea-${TEA_VERSION}-linux-amd64" -O tea chmod +x tea mv tea /usr/local/bin/tea - name: Verify Tea Installation run: tea --version - name: Add Gitea Login env: GITEA_URL: ${{ secrets._GITEA_URL }} GITEA_TOKEN: ${{ secrets._GITEA_TOKEN }} run: | if [ -z "$GITEA_URL" ]; then echo "Error: GITEA_URL secret is not set." exit 1 fi if [ -z "$GITEA_TOKEN" ]; then echo "Error: GITEA_TOKEN secret is not set." exit 1 fi tea login add --name mygitea --url "$GITEA_URL" --token "$GITEA_TOKEN" --insecure ${{ startsWith(secrets._GITEA_URL, 'http://') || '' }} - name: Install bun uses: oven-sh/setup-bun@v2 - name: Install claude code run: bun i -g @anthropic-ai/claude-code - name: Get PR Diff id: get_pr_diff run: | # Fetch the base branch to get the diff accurately git fetch origin main:main DIFF=$(git diff main...HEAD) # Escape quotes and other special characters for the multiline string ESCAPED_DIFF=$(echo "$DIFF" | sed 's/"/\\"/g' | sed ':a;N;$!ba;s/\n/\\n/g') echo "diff=$ESCAPED_DIFF" >> "$GITHUB_OUTPUT" - name: Gemini PR Review if: steps.check-renovate.outputs.author != 'Renovate Bot' env: ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} PR_NUMBER: ${{ github.event.number }} PR_DIFF: ${{ steps.get_pr_diff.outputs.diff }} run: | ANTHROPIC_BASE_URL=${{ secrets.ANTHROPIC_BASE_URL }} claude --allowedTools "Bash(tea:*)" --allowedTools "Bash(git:*) Read Grep WebFetch Glob LS" -p "You are a code review assistant. Your task is to review the changes in Pull Request #${PR_NUMBER}. The relevant changes are provided as a git diff below. --- Start of PR Diff --- ${PR_DIFF} --- End of PR Diff --- Only provide constructive feedback on the quality, correctness, readability, and potential issues in the code based on the provided diff. Do not make any changes or suggest complete rewrites—just review what is there. You can use the rest of the repository as context if needed, but focus your review on the changes shown in the diff. Once you are done with your review, post your feedback as a reject or review on the pull request using the following exact format: tea \"\" ${PR_NUMBER} \"\" Make sure the comment is clear, professional, and helpful. Only run the tea comment command once you're finished reviewing all changes. ALWAYS PUT A COMMENT You may also use the tea cli to find out various things about the pull request. Don't be too strict. Also MAKE SURE TO ALWAYS MENTION WHAT FILES AND LINE NUMBERS ARE WRONG. Use the tea cli at all cost."