|
| 1 | +name: '🔎 Gemini Review' |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + additional_context: |
| 7 | + type: 'string' |
| 8 | + description: 'Any additional context from the request' |
| 9 | + required: false |
| 10 | + secrets: |
| 11 | + GEMINI_API_KEY: |
| 12 | + description: 'Gemini API Key' |
| 13 | + required: true |
| 14 | + GOOGLE_API_KEY: |
| 15 | + description: 'Google API Key' |
| 16 | + required: false |
| 17 | + APP_PRIVATE_KEY: |
| 18 | + description: 'Mint identity private key' |
| 19 | + required: false |
| 20 | + |
| 21 | +concurrency: |
| 22 | + group: '${{ github.workflow }}-review-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.issue.number }}' |
| 23 | + cancel-in-progress: true |
| 24 | + |
| 25 | +defaults: |
| 26 | + run: |
| 27 | + shell: 'bash' |
| 28 | + |
| 29 | +jobs: |
| 30 | + review: |
| 31 | + runs-on: 'ubuntu-latest' |
| 32 | + timeout-minutes: 7 |
| 33 | + permissions: |
| 34 | + contents: 'read' |
| 35 | + id-token: 'write' |
| 36 | + issues: 'write' |
| 37 | + pull-requests: 'write' |
| 38 | + steps: |
| 39 | + - name: 'Mint identity token' |
| 40 | + id: 'mint_identity_token' |
| 41 | + if: |- |
| 42 | + ${{ vars.APP_ID }} |
| 43 | + uses: 'actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf' # ratchet:actions/create-github-app-token@v2 |
| 44 | + with: |
| 45 | + app-id: '${{ vars.APP_ID }}' |
| 46 | + private-key: '${{ secrets.APP_PRIVATE_KEY }}' |
| 47 | + permission-contents: 'read' |
| 48 | + permission-issues: 'write' |
| 49 | + permission-pull-requests: 'write' |
| 50 | + |
| 51 | + - name: 'Checkout repository' |
| 52 | + uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # ratchet:actions/checkout@v6 |
| 53 | + with: |
| 54 | + persist-credentials: false |
| 55 | + |
| 56 | + - name: 'Run Gemini pull request review' |
| 57 | + uses: 'google-github-actions/run-gemini-cli@5a3b23c898e09c9a9d00e75f7725e83ed603884d' # v0.1.19 |
| 58 | + id: 'gemini_pr_review' |
| 59 | + env: |
| 60 | + GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}' |
| 61 | + ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}' |
| 62 | + ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}' |
| 63 | + PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}' |
| 64 | + REPOSITORY: '${{ github.repository }}' |
| 65 | + ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}' |
| 66 | + with: |
| 67 | + gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}' |
| 68 | + gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}' |
| 69 | + gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}' |
| 70 | + gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}' |
| 71 | + gemini_api_key: '${{ secrets.GEMINI_API_KEY }}' |
| 72 | + gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}' |
| 73 | + gemini_debug: '${{ fromJSON(vars.GEMINI_DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}' |
| 74 | + gemini_model: '${{ vars.GEMINI_MODEL }}' |
| 75 | + google_api_key: '${{ secrets.GOOGLE_API_KEY }}' |
| 76 | + use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}' |
| 77 | + use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' |
| 78 | + upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' |
| 79 | + workflow_name: 'gemini-review' |
| 80 | + settings: |- |
| 81 | + { |
| 82 | + "model": { |
| 83 | + "maxSessionTurns": 25 |
| 84 | + }, |
| 85 | + "telemetry": { |
| 86 | + "enabled": true, |
| 87 | + "target": "local", |
| 88 | + "outfile": ".gemini/telemetry.log" |
| 89 | + }, |
| 90 | + "mcpServers": { |
| 91 | + "github": { |
| 92 | + "command": "docker", |
| 93 | + "args": [ |
| 94 | + "run", |
| 95 | + "-i", |
| 96 | + "--rm", |
| 97 | + "-e", |
| 98 | + "GITHUB_PERSONAL_ACCESS_TOKEN", |
| 99 | + "ghcr.io/github/github-mcp-server:v0.27.0" |
| 100 | + ], |
| 101 | + "includeTools": [ |
| 102 | + "add_comment_to_pending_review", |
| 103 | + "pull_request_read", |
| 104 | + "pull_request_review_write" |
| 105 | + ], |
| 106 | + "env": { |
| 107 | + "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" |
| 108 | + } |
| 109 | + } |
| 110 | + }, |
| 111 | + "tools": { |
| 112 | + "core": [ |
| 113 | + "run_shell_command(cat)", |
| 114 | + "run_shell_command(echo)", |
| 115 | + "run_shell_command(grep)", |
| 116 | + "run_shell_command(head)", |
| 117 | + "run_shell_command(tail)" |
| 118 | + ] |
| 119 | + } |
| 120 | + } |
| 121 | + prompt: '/gemini-review' |
0 commit comments