-
Notifications
You must be signed in to change notification settings - Fork 7.8k
[Experiment DNM] Adds Gemini CLI to Github Actions #2718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
ericwindmill
wants to merge
7
commits into
main
Choose a base branch
from
gemini-cli-actions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+29,278
−27,742
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
9801f24
[LLM release] Dart 3.9 / Flutter 3.35 (#2701)
ericwindmill 0687f72
organize gemini docs
ericwindmill baba805
update llm instructions
ericwindmill 63c617f
update llm instructions
ericwindmill 109938c
update llm instructions
ericwindmill 468ad33
update llm instructions
ericwindmill 913cf38
adds gemini workflows
ericwindmill File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"mcpServers": { | ||
"dart": { | ||
"command": "dart", | ||
"args": [ | ||
"mcp-server" | ||
] | ||
} | ||
}, | ||
"contextFileName": "/.prompts/llm.md" | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
name: '🏷️ Gemini Automated Issue Triage' | ||
|
||
on: | ||
issues: | ||
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: | ||
triage-issue: | ||
if: > | ||
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 | ||
runs-on: 'ubuntu-latest' | ||
|
||
steps: | ||
- name: 'Checkout repository' | ||
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4 | ||
|
||
- name: 'Generate GitHub App Token' | ||
id: 'generate_token' | ||
if: |- | ||
${{ vars.APP_ID }} | ||
uses: 'actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e' # ratchet:actions/create-github-app-token@v2 | ||
with: | ||
app-id: '${{ vars.APP_ID }}' | ||
private-key: '${{ secrets.APP_PRIVATE_KEY }}' | ||
|
||
- name: 'Run Gemini Issue Triage' | ||
uses: 'google-github-actions/run-gemini-cli@v0' | ||
id: 'gemini_issue_triage' | ||
env: | ||
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}' | ||
ISSUE_TITLE: '${{ github.event.issue.title }}' | ||
ISSUE_BODY: '${{ github.event.issue.body }}' | ||
ISSUE_NUMBER: '${{ github.event.issue.number }}' | ||
REPOSITORY: '${{ github.repository }}' | ||
with: | ||
gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}' | ||
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": [ | ||
"run_shell_command(gh label list)", | ||
"run_shell_command(gh issue edit)" | ||
], | ||
"telemetry": { | ||
"enabled": false, | ||
"target": "gcp" | ||
} | ||
} | ||
prompt: |- | ||
## Role | ||
|
||
You are an issue triage assistant. Analyze the current GitHub issue | ||
and apply the most appropriate existing labels. Use the available | ||
tools to gather information; do not ask for information to be | ||
provided. | ||
|
||
## Steps | ||
|
||
1. Run: `gh label list` to get all available labels. | ||
2. Review the issue title and body provided in the environment | ||
variables: "${ISSUE_TITLE}" and "${ISSUE_BODY}". | ||
3. Select the most relevant labels from the existing labels. If | ||
available, set labels that follow the `kind/*`, `area/*`, and | ||
`priority/*` patterns. | ||
4. Apply the selected labels to this issue using: | ||
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"` | ||
5. If the "status/needs-triage" label is present, remove it using: | ||
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"` | ||
|
||
## Guidelines | ||
|
||
- Only use labels that already exist in the repository | ||
- Do not add comments or modify the issue content | ||
- Triage only the current issue | ||
- Assign all applicable labels based on the issue content | ||
- Reference all shell variables as "${VAR}" (with quotes and braces) | ||
|
||
- 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 || secrets.GITHUB_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.' | ||
}) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
name: '📋 Gemini Scheduled Issue Triage' | ||
|
||
on: | ||
schedule: | ||
- cron: '0 * * * *' # Runs every hour | ||
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: | ||
triage-issues: | ||
timeout-minutes: 5 | ||
runs-on: 'ubuntu-latest' | ||
|
||
steps: | ||
- name: 'Checkout repository' | ||
uses: 'actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683' # ratchet:actions/checkout@v4 | ||
|
||
- name: 'Generate GitHub App Token' | ||
id: 'generate_token' | ||
if: |- | ||
${{ vars.APP_ID }} | ||
uses: 'actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e' # ratchet:actions/create-github-app-token@v2 | ||
with: | ||
app-id: '${{ vars.APP_ID }}' | ||
private-key: '${{ secrets.APP_PRIVATE_KEY }}' | ||
|
||
- name: 'Find untriaged issues' | ||
id: 'find_issues' | ||
env: | ||
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}' | ||
GITHUB_REPOSITORY: '${{ github.repository }}' | ||
GITHUB_OUTPUT: '${{ github.output }}' | ||
run: |- | ||
set -euo pipefail | ||
|
||
echo '🔍 Finding issues without labels...' | ||
NO_LABEL_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \ | ||
--search 'is:open is:issue no:label' --json number,title,body)" | ||
|
||
echo '🏷️ Finding issues that need triage...' | ||
NEED_TRIAGE_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \ | ||
--search 'is:open is:issue label:"status/needs-triage"' --json number,title,body)" | ||
|
||
echo '🔄 Merging and deduplicating issues...' | ||
ISSUES="$(echo "${NO_LABEL_ISSUES}" "${NEED_TRIAGE_ISSUES}" | jq -c -s 'add | unique_by(.number)')" | ||
|
||
echo '📝 Setting output for GitHub Actions...' | ||
echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}" | ||
|
||
ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')" | ||
echo "✅ Found ${ISSUE_COUNT} issues to triage! 🎯" | ||
|
||
- name: 'Run Gemini Issue Triage' | ||
if: |- | ||
${{ steps.find_issues.outputs.issues_to_triage != '[]' }} | ||
uses: 'google-github-actions/run-gemini-cli@v0' | ||
id: 'gemini_issue_triage' | ||
env: | ||
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}' | ||
ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}' | ||
REPOSITORY: '${{ github.repository }}' | ||
with: | ||
gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}' | ||
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": [ | ||
"run_shell_command(echo)", | ||
"run_shell_command(gh label list)", | ||
"run_shell_command(gh issue edit)", | ||
"run_shell_command(gh issue list)" | ||
], | ||
"telemetry": { | ||
"enabled": false, | ||
"target": "gcp" | ||
} | ||
} | ||
prompt: |- | ||
## Role | ||
|
||
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` | ||
2. Check environment variable: "${ISSUES_TO_TRIAGE}" (JSON array | ||
of issues) | ||
3. For each issue, apply labels: | ||
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"`. | ||
If available, set labels that follow the `kind/*`, `area/*`, | ||
and `priority/*` patterns. | ||
4. For each issue, if the `status/needs-triage` label is present, | ||
remove it using: | ||
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"` | ||
|
||
## Guidelines | ||
|
||
- Only use existing repository labels | ||
- Do not add comments | ||
- Triage each issue independently | ||
- Reference all shell variables as "${VAR}" (with quotes and braces) |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 You can use the
contains
function to simplify the author association check, making the condition more readable and maintainable.