From 2a73e0e4d157c8290c25c718f614d19d3f3efa2f Mon Sep 17 00:00:00 2001 From: Felipe Lima Date: Thu, 28 May 2026 16:14:49 -0400 Subject: [PATCH] chore(ci): add ai review workflow --- .github/workflows/ai-review.yml | 64 +++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 .github/workflows/ai-review.yml diff --git a/.github/workflows/ai-review.yml b/.github/workflows/ai-review.yml new file mode 100644 index 00000000..b23943bf --- /dev/null +++ b/.github/workflows/ai-review.yml @@ -0,0 +1,64 @@ +name: AI Review + +on: + pull_request: + types: [opened, ready_for_review] + issue_comment: + types: [created] + +jobs: + parse: + if: | + github.event_name == 'pull_request' || + (github.event_name == 'issue_comment' && + github.event.issue.pull_request != null && + startsWith(github.event.comment.body, '/review')) + runs-on: ubuntu-latest + outputs: + model: ${{ steps.p.outputs.model }} + effort: ${{ steps.p.outputs.effort }} + steps: + - id: p + env: + DEFAULT_MODEL: x-ai/grok-build-0.1 + DEFAULT_EFFORT: high + EVENT_NAME: ${{ github.event_name }} + COMMENT_BODY: ${{ github.event.comment.body }} + run: | + if [ "$EVENT_NAME" != "issue_comment" ]; then + echo "model=$DEFAULT_MODEL" >> "$GITHUB_OUTPUT" + echo "effort=$DEFAULT_EFFORT" >> "$GITHUB_OUTPUT" + echo "Auto-fire on PR event: model=$DEFAULT_MODEL effort=$DEFAULT_EFFORT" + exit 0 + fi + ARGS=$(printf '%s' "$COMMENT_BODY" | head -n1 | sed 's|^/review||' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//') + if [ -z "$ARGS" ]; then + MODEL="$DEFAULT_MODEL" + EFFORT="$DEFAULT_EFFORT" + else + MODEL="${ARGS%%:*}" + case "$ARGS" in + *:*) EFFORT="${ARGS#*:}" ;; + *) EFFORT="$DEFAULT_EFFORT" ;; + esac + fi + echo "model=$MODEL" >> "$GITHUB_OUTPUT" + echo "effort=$EFFORT" >> "$GITHUB_OUTPUT" + echo "Parsed /review: model=$MODEL effort=$EFFORT" + + review: + needs: parse + permissions: + contents: write + pull-requests: write + concurrency: + group: ai-review-${{ github.event.pull_request.number || github.event.issue.number }}-${{ needs.parse.outputs.model }} + cancel-in-progress: true + uses: tago-io/actions/.github/workflows/pr-review.yml@main + with: + model: ${{ needs.parse.outputs.model }} + effort: ${{ needs.parse.outputs.effort }} + secrets: + TAGOIO_AGENT_APP_CLIENT_ID: ${{ secrets.TAGOIO_AGENT_APP_CLIENT_ID }} + TAGOIO_AGENT_APP_PRIVATE_KEY: ${{ secrets.TAGOIO_AGENT_APP_PRIVATE_KEY }} + OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}