Skip to content

Commit 5c841bf

Browse files
committed
feat: Initial implementation of the Gemini CLI GitHub Action
This commit introduces the core implementation of the Gemini CLI GitHub Action, establishing its primary features and structure. Key features and additions include: - **Composite Action:** The action is built as a composite action, directly installing and running the Gemini CLI for efficiency and simplicity. - **Workflows:** Includes example workflows for key use cases: - Automated and scheduled issue triage. - Pull request reviews. - **Documentation:** Comprehensive documentation is added for: - Configuration and setup. - Authentication using GitHub Apps and Google Cloud Workload Identity Federation. - Observability with OpenTelemetry. - **Scripts:** Helper scripts are provided to facilitate the setup of Workload Identity and OpenTelemetry. - **Project Files:** - is configured with inputs for the CLI. - , , and provide usage and contribution guidelines.
1 parent dac2fd4 commit 5c841bf

33 files changed

Lines changed: 2609 additions & 2685 deletions

.github/dependabot.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
---
12
version: 2
23
updates:
34
- package-ecosystem: 'npm'
@@ -7,4 +8,4 @@ updates:
78
interval: 'daily'
89
commit-message:
910
prefix: 'security: '
10-
open-pull-requests-limit: 0 # only check security updates
11+
open-pull-requests-limit: 0 # only check security updates

.github/workflows/draft-release.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
---
12
name: 'Draft release'
23

3-
on:
4+
on: # yamllint disable-line rule:truthy
45
workflow_dispatch:
56
inputs:
67
version_strategy:
@@ -19,7 +20,7 @@ permissions:
1920

2021
jobs:
2122
draft-release:
22-
uses: 'google-github-actions/.github/.github/workflows/draft-release.yml@v3' # ratchet:exclude
23+
uses: 'google-github-actions/.github/.github/workflows/draft-release.yml@v3' # ratchet:exclude
2324
with:
2425
version_strategy: '${{ github.event.inputs.version_strategy }}'
2526
secrets:
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
name: '🏷️ Gemini Automated Issue Triage'
3+
on: # yamllint disable-line rule:truthy
4+
issues:
5+
types:
6+
- 'opened'
7+
- 'reopened'
8+
9+
jobs:
10+
triage-issue:
11+
timeout-minutes: 5
12+
permissions:
13+
issues: 'write'
14+
contents: 'read'
15+
id-token: 'write'
16+
concurrency:
17+
group: '${{ github.workflow }}-${{ github.event.issue.number }}'
18+
# yamllint disable-line rule:truthy
19+
cancel-in-progress: true
20+
runs-on: 'ubuntu-latest'
21+
steps:
22+
- name: 'Checkout repository'
23+
uses: 'actions/checkout@v4'
24+
25+
- name: 'Generate GitHub App Token'
26+
id: 'generate_token'
27+
if: ${{ vars.APP_ID }}
28+
uses: 'actions/create-github-app-token@v1'
29+
with:
30+
app-id: '${{ vars.APP_ID }}'
31+
private-key: '${{ secrets.APP_PRIVATE_KEY }}'
32+
33+
- name: 'Run Gemini Issue Triage'
34+
uses: './'
35+
env:
36+
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
37+
ISSUE_TITLE: '${{ github.event.issue.title }}'
38+
ISSUE_BODY: '${{ github.event.issue.body }}'
39+
ISSUE_NUMBER: '${{ github.event.issue.number }}'
40+
REPOSITORY: '${{ github.repository }}'
41+
GEMINI_CLI_VERSION: '${{ vars.GEMINI_CLI_VERSION }}'
42+
OTLP_GOOGLE_CLOUD_PROJECT: '${{ vars.OTLP_GOOGLE_CLOUD_PROJECT }}'
43+
OTLP_GCP_WIF_PROVIDER: '${{ vars.OTLP_GCP_WIF_PROVIDER }}'
44+
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
45+
with:
46+
settings_json: |
47+
{
48+
"coreTools": [
49+
"run_shell_command(gh label list)",
50+
"run_shell_command(gh issue edit)"
51+
],
52+
"telemetry": {
53+
"enabled": true,
54+
"target": "gcp"
55+
},
56+
"sandbox": false
57+
}
58+
prompt: |
59+
## Role
60+
61+
You are an issue triage assistant. Analyze the current GitHub issue
62+
and apply the most appropriate existing labels. Use the available
63+
tools to gather information; do not ask for information to be
64+
provided.
65+
66+
## Steps
67+
68+
1. Run: `gh label list` to get all available labels.
69+
2. Review the issue title and body provided in the environment
70+
variables: "${ISSUE_TITLE}" and "${ISSUE_BODY}".
71+
3. Select the most relevant labels from the existing labels. If
72+
available, set labels that follow the `kind/*`, `area/*`, and
73+
`priority/*` patterns.
74+
4. Apply the selected labels to this issue using:
75+
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"`
76+
5. If the "status/needs-triage" label is present, remove it using:
77+
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"`
78+
79+
## Guidelines
80+
81+
- Only use labels that already exist in the repository
82+
- Do not add comments or modify the issue content
83+
- Triage only the current issue
84+
- Assign all applicable labels based on the issue content
85+
- Reference all shell variables as "${VAR}" (with quotes and braces)
Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
---
2+
name: '📋 Gemini Scheduled Issue Triage'
3+
4+
on: # yamllint disable-line rule:truthy
5+
schedule:
6+
- cron: '0 * * * *' # Runs every hour
7+
workflow_dispatch:
8+
9+
jobs:
10+
triage-issues:
11+
timeout-minutes: 10
12+
runs-on: 'ubuntu-latest'
13+
permissions:
14+
contents: 'read'
15+
id-token: 'write'
16+
issues: 'write'
17+
steps:
18+
- name: 'Checkout repository'
19+
uses: 'actions/checkout@v4'
20+
21+
- name: 'Generate GitHub App Token'
22+
id: 'generate_token'
23+
if: ${{ vars.APP_ID }}
24+
uses: 'actions/create-github-app-token@v1'
25+
with:
26+
app-id: '${{ vars.APP_ID }}'
27+
private-key: '${{ secrets.APP_PRIVATE_KEY }}'
28+
29+
- name: 'Find untriaged issues'
30+
id: 'find_issues'
31+
env:
32+
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
33+
GITHUB_REPOSITORY: '${{ github.repository }}'
34+
GITHUB_OUTPUT: '${{ github.output }}'
35+
shell: bash
36+
run: |
37+
set -euo pipefail
38+
39+
echo '🔍 Finding issues without labels...'
40+
NO_LABEL_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
41+
--search 'is:open is:issue no:label' --json number,title,body)"
42+
43+
echo '🏷️ Finding issues that need triage...'
44+
NEED_TRIAGE_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
45+
--search 'is:open is:issue label:"status/needs-triage"' --json number,title,body)"
46+
47+
echo '🔄 Merging and deduplicating issues...'
48+
ISSUES="$(echo "${NO_LABEL_ISSUES}" "${NEED_TRIAGE_ISSUES}" | jq -c -s 'add | unique_by(.number)')"
49+
50+
echo '📝 Setting output for GitHub Actions...'
51+
echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}"
52+
53+
ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')"
54+
echo "✅ Found ${ISSUE_COUNT} issues to triage! 🎯"
55+
56+
- name: 'Run Gemini Issue Triage'
57+
if: steps.find_issues.outputs.issues_to_triage != '[]'
58+
uses: './'
59+
env:
60+
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token }}'
61+
ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}'
62+
REPOSITORY: '${{ github.repository }}'
63+
GEMINI_CLI_VERSION: '${{ vars.GEMINI_CLI_VERSION }}'
64+
OTLP_GOOGLE_CLOUD_PROJECT: '${{ vars.OTLP_GOOGLE_CLOUD_PROJECT }}'
65+
OTLP_GCP_WIF_PROVIDER: '${{ vars.OTLP_GCP_WIF_PROVIDER }}'
66+
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
67+
with:
68+
settings_json: |
69+
{
70+
"coreTools": [
71+
"run_shell_command(echo)",
72+
"run_shell_command(gh label list)",
73+
"run_shell_command(gh issue edit)",
74+
"run_shell_command(gh issue list)"
75+
],
76+
"telemetry": {
77+
"enabled": true,
78+
"target": "gcp"
79+
},
80+
"sandbox": false
81+
}
82+
prompt: |
83+
## Role
84+
85+
You are an issue triage assistant. Analyze issues and apply
86+
appropriate labels. Use the available tools to gather information;
87+
do not ask for information to be provided.
88+
89+
## Steps
90+
91+
1. Run: `gh label list`
92+
2. Check environment variable: "${ISSUES_TO_TRIAGE}" (JSON array
93+
of issues)
94+
3. For each issue, apply labels:
95+
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"`.
96+
If available, set labels that follow the `kind/*`, `area/*`,
97+
and `priority/*` patterns.
98+
4. For each issue, if the `status/needs-triage` label is present,
99+
remove it using:
100+
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"`
101+
102+
## Guidelines
103+
104+
- Only use existing repository labels
105+
- Do not add comments
106+
- Triage each issue independently
107+
- Reference all shell variables as "${VAR}" (with quotes and braces)

0 commit comments

Comments
 (0)