refactor: use `google-github-actions/run-gemini-cli` action (#5643)

This commit is contained in:
Gaurav 2025-08-05 19:24:40 -07:00 committed by GitHub
parent 7e5a5e2da7
commit b87b436ebc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 168 additions and 80 deletions

View File

@ -1,56 +1,95 @@
name: Gemini Automated Issue Triage name: '🏷️ Gemini Automated Issue Triage'
on: on:
issues: issues:
types: [opened, reopened] types:
- 'opened'
- 'reopened'
issue_comment:
types:
- 'created'
workflow_dispatch:
inputs:
issue_number:
description: 'issue number to triage'
required: true
type: 'number'
concurrency:
group: '${{ github.workflow }}-${{ github.event.issue.number }}'
cancel-in-progress: true
defaults:
run:
shell: 'bash'
permissions:
contents: 'read'
id-token: 'write'
issues: 'write'
statuses: 'write'
jobs: jobs:
triage-issue: triage-issue:
if: >
github.repository == 'google-gemini/gemini-cli' &&
(github.event_name == 'issues' ||
github.event_name == 'workflow_dispatch' ||
(github.event_name == 'issue_comment' &&
contains(github.event.comment.body, '@gemini-cli /triage') &&
(github.event.comment.author_association == 'OWNER' ||
github.event.comment.author_association == 'MEMBER' ||
github.event.comment.author_association == 'COLLABORATOR')))
timeout-minutes: 5 timeout-minutes: 5
if: ${{ github.repository == 'google-gemini/gemini-cli' }} runs-on: 'ubuntu-latest'
permissions:
issues: write
contents: read
id-token: write
concurrency:
group: ${{ github.workflow }}-${{ github.event.issue.number }}
cancel-in-progress: true
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App Token
id: generate_token
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
- name: Run Gemini Issue Triage steps:
uses: google-gemini/gemini-cli-action@df3f890f003d28c60a2a09d2c29e0126e4d1e2ff - name: 'Checkout repository'
env: uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683'
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
ISSUE_TITLE: ${{ github.event.issue.title }} - name: 'Generate GitHub App Token'
ISSUE_BODY: ${{ github.event.issue.body }} id: 'generate_token'
uses: 'actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e'
with: with:
version: 0.1.8-rc.0 app-id: '${{ secrets.APP_ID }}'
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} private-key: '${{ secrets.PRIVATE_KEY }}'
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }}
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }} - name: 'Run Gemini Issue Triage'
settings_json: | uses: 'google-github-actions/run-gemini-cli@68d5a6d2e31ff01029205c58c6bf81cb3d72910b'
id: 'gemini_issue_triage'
env:
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
ISSUE_TITLE: '${{ github.event.issue.title }}'
ISSUE_BODY: '${{ github.event.issue.body }}'
ISSUE_NUMBER: '${{ github.event.issue.number }}'
REPOSITORY: '${{ github.repository }}'
with:
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
settings: |-
{ {
"maxSessionTurns": 25,
"coreTools": [ "coreTools": [
"run_shell_command(gh label list)", "run_shell_command(gh label list)",
"run_shell_command(gh issue edit)", "run_shell_command(gh issue edit)"
"run_shell_command(gh issue list)"
], ],
"telemetry": { "telemetry": {
"enabled": true, "enabled": true,
"target": "gcp" "target": "gcp"
}, }
"sandbox": false
} }
prompt: | prompt: |-
## Role
You are an issue triage assistant. Analyze the current GitHub issues apply the most appropriate existing labels. Do not remove labels titled help wanted or good first issue. You are an issue triage assistant. Analyze the current GitHub issues apply the most appropriate existing labels. Do not remove labels titled help wanted or good first issue.
Steps:
## Steps
1. Run: `gh label list --repo ${{ github.repository }} --limit 100` to get all available labels. 1. Run: `gh label list --repo ${{ github.repository }} --limit 100` to get all available labels.
2. Review the issue title, body and any comments provided in the environment variables. 2. Review the issue title, body and any comments provided in the environment variables.
3. Ignore any existing priorities or tags on the issue. Just report your findings. 3. Ignore any existing priorities or tags on the issue. Just report your findings.
@ -59,7 +98,9 @@ jobs:
7. For each issue please check if CLI version is present, this is usually in the output of the /about command and will look like 0.1.5 for anything more than 6 versions older than the most recent should add the status/need-retesting label 7. For each issue please check if CLI version is present, this is usually in the output of the /about command and will look like 0.1.5 for anything more than 6 versions older than the most recent should add the status/need-retesting label
8. If you see that the issue doesnt look like it has sufficient information recommend the status/need-information label 8. If you see that the issue doesnt look like it has sufficient information recommend the status/need-information label
9. Use Area definitions mentioned below to help you narrow down issues 9. Use Area definitions mentioned below to help you narrow down issues
Guidelines:
## Guidelines
- Only use labels that already exist in the repository. - Only use labels that already exist in the repository.
- Do not add comments or modify the issue content. - Do not add comments or modify the issue content.
- Triage only the current issue. - Triage only the current issue.
@ -143,3 +184,17 @@ jobs:
- could also pertain to latency, - could also pertain to latency,
- other general software performance like, memory usage, CPU consumption, and algorithmic efficiency. - other general software performance like, memory usage, CPU consumption, and algorithmic efficiency.
- Switching models from one to the other unexpectedly. - Switching models from one to the other unexpectedly.
- name: 'Post Issue Triage Failure Comment'
if: |-
${{ failure() && steps.gemini_issue_triage.outcome == 'failure' }}
uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea'
with:
github-token: '${{ steps.generate_token.outputs.token }}'
script: |-
github.rest.issues.createComment({
owner: '${{ github.repository }}'.split('/')[0],
repo: '${{ github.repository }}'.split('/')[1],
issue_number: '${{ github.event.issue.number }}',
body: 'There is a problem with the Gemini CLI issue triaging. Please check the [action logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.'
})

View File

@ -1,76 +1,107 @@
name: Gemini Scheduled Issue Triage name: '📋 Gemini Scheduled Issue Triage'
on: on:
schedule: schedule:
- cron: '0 * * * *' # Runs every hour - cron: '0 * * * *' # Runs every hour
workflow_dispatch: {} workflow_dispatch:
concurrency:
group: '${{ github.workflow }}'
cancel-in-progress: true
defaults:
run:
shell: 'bash'
permissions:
contents: 'read'
id-token: 'write'
issues: 'write'
statuses: 'write'
jobs: jobs:
triage-issues: triage-issues:
timeout-minutes: 10 timeout-minutes: 10
if: ${{ github.repository == 'google-gemini/gemini-cli' }} if: ${{ github.repository == 'google-gemini/gemini-cli' }}
runs-on: ubuntu-latest runs-on: 'ubuntu-latest'
permissions:
contents: read
id-token: write
issues: write
steps: steps:
- name: Generate GitHub App Token - name: 'Checkout repository'
id: generate_token uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2
- name: 'Generate GitHub App Token'
id: 'generate_token'
uses: 'actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e' # ratchet:actions/create-github-app-token@v2
with: with:
app-id: ${{ secrets.APP_ID }} app-id: '${{ secrets.APP_ID }}'
private-key: ${{ secrets.PRIVATE_KEY }} private-key: '${{ secrets.PRIVATE_KEY }}'
- name: Find untriaged issues - name: 'Find untriaged issues'
id: find_issues id: 'find_issues'
env: env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
run: | GITHUB_REPOSITORY: '${{ github.repository }}'
echo "🔍 Finding issues without labels..." GITHUB_OUTPUT: '${{ github.output }}'
NO_LABEL_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue no:label" --json number,title,body) run: |-
set -euo pipefail
echo "🏷️ Finding issues that need triage..." echo '🔍 Finding issues without labels...'
NEED_TRIAGE_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue label:\"status/need-triage\"" --json number,title,body) NO_LABEL_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
--search 'is:open is:issue no:label' --json number,title,body)"
echo "🔄 Merging and deduplicating issues..." echo '🏷️ Finding issues that need triage...'
ISSUES=$(echo "$NO_LABEL_ISSUES" "$NEED_TRIAGE_ISSUES" | jq -c -s 'add | unique_by(.number)') NEED_TRIAGE_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
--search 'is:open is:issue label:"status/needs-triage"' --json number,title,body)"
echo "📝 Setting output for GitHub Actions..." echo '🔄 Merging and deduplicating issues...'
echo "issues_to_triage=$ISSUES" >> "$GITHUB_OUTPUT" ISSUES="$(echo "${NO_LABEL_ISSUES}" "${NEED_TRIAGE_ISSUES}" | jq -c -s 'add | unique_by(.number)')"
echo "✅ Found $(echo "$ISSUES" | jq 'length') issues to triage! 🎯" echo '📝 Setting output for GitHub Actions...'
echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}"
- name: Run Gemini Issue Triage ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')"
if: steps.find_issues.outputs.issues_to_triage != '[]' echo "✅ Found ${ISSUE_COUNT} issues to triage! 🎯"
uses: google-gemini/gemini-cli-action@df3f890f003d28c60a2a09d2c29e0126e4d1e2ff
- name: 'Run Gemini Issue Triage'
if: |-
${{ steps.find_issues.outputs.issues_to_triage != '[]' }}
uses: 'google-github-actions/run-gemini-cli@68d5a6d2e31ff01029205c58c6bf81cb3d72910b'
id: 'gemini_issue_triage'
env: env:
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
ISSUES_TO_TRIAGE: ${{ steps.find_issues.outputs.issues_to_triage }} ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}'
REPOSITORY: ${{ github.repository }} REPOSITORY: '${{ github.repository }}'
with: with:
version: 0.1.8-rc.0 gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }} gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }} gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }} gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
settings_json: | gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
settings: |-
{ {
"maxSessionTurns": 25,
"coreTools": [ "coreTools": [
"run_shell_command(echo)", "run_shell_command(echo)",
"run_shell_command(gh label list)", "run_shell_command(gh label list)",
"run_shell_command(gh issue edit)", "run_shell_command(gh issue edit)",
"run_shell_command(gh issue list)",
"run_shell_command(gh issue view)" "run_shell_command(gh issue view)"
], ],
"telemetry": { "telemetry": {
"enabled": true, "enabled": true,
"target": "gcp" "target": "gcp"
}, }
"sandbox": false
} }
prompt: | prompt: |-
You are an issue triage assistant. Analyze the current GitHub issues apply the most appropriate existing labels. ## Role
Steps:
You are an issue triage assistant. Analyze issues and apply
appropriate labels. Use the available tools to gather information;
do not ask for information to be provided.
## Steps
1. Run: `gh label list --repo ${{ github.repository }} --limit 100` to get all available labels. 1. Run: `gh label list --repo ${{ github.repository }} --limit 100` to get all available labels.
2. Check environment variable for issues to triage: $ISSUES_TO_TRIAGE (JSON array of issues) 2. Check environment variable for issues to triage: $ISSUES_TO_TRIAGE (JSON array of issues)
3. Review the issue title, body and any comments provided in the environment variables. 3. Review the issue title, body and any comments provided in the environment variables.
@ -95,8 +126,10 @@ jobs:
- After applying appropriate labels to an issue, remove the "status/need-triage" label if present: `gh issue edit ISSUE_NUMBER --repo ${{ github.repository }} --remove-label "status/need-triage"` - After applying appropriate labels to an issue, remove the "status/need-triage" label if present: `gh issue edit ISSUE_NUMBER --repo ${{ github.repository }} --remove-label "status/need-triage"`
- Execute one `gh issue edit` command per issue, wait for success before proceeding to the next - Execute one `gh issue edit` command per issue, wait for success before proceeding to the next
Process each issue sequentially and confirm each labeling operation before moving to the next issue. Process each issue sequentially and confirm each labeling operation before moving to the next issue.
Guidelines:
- Only use labels that already exist in the repository. ## Guidelines
- Only use labels that already exist in the repository.
- Do not add comments or modify the issue content. - Do not add comments or modify the issue content.
- Do not remove labels titled help wanted or good first issue. - Do not remove labels titled help wanted or good first issue.
- Triage only the current issue. - Triage only the current issue.