Skip to content

Commit 5010b2f

Browse files
committed
chore: Add Issues Triage GH actions back
1 parent 8cdf5a9 commit 5010b2f

2 files changed

Lines changed: 235 additions & 0 deletions

File tree

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
name: '🏷️ Gemini Automated Issue Triage'
2+
3+
on:
4+
issues:
5+
types:
6+
- 'opened'
7+
- 'reopened'
8+
issue_comment:
9+
types:
10+
- 'created'
11+
workflow_dispatch:
12+
inputs:
13+
issue_number:
14+
description: 'issue number to triage'
15+
required: true
16+
type: 'number'
17+
18+
concurrency:
19+
group: '${{ github.workflow }}-${{ github.event.issue.number }}'
20+
cancel-in-progress: true
21+
22+
defaults:
23+
run:
24+
shell: 'bash'
25+
26+
permissions:
27+
contents: 'read'
28+
id-token: 'write'
29+
issues: 'write'
30+
statuses: 'write'
31+
32+
jobs:
33+
triage-issue:
34+
if: |-
35+
github.event_name == 'issues' ||
36+
github.event_name == 'workflow_dispatch' ||
37+
(
38+
github.event_name == 'issue_comment' &&
39+
contains(github.event.comment.body, '@gemini-cli /triage') &&
40+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association)
41+
)
42+
timeout-minutes: 5
43+
runs-on: 'ubuntu-latest'
44+
45+
steps:
46+
- name: 'Checkout repository'
47+
uses: 'actions/checkout@v5'
48+
49+
- name: 'Run Gemini Issue Triage'
50+
uses: './'
51+
id: 'gemini_issue_triage'
52+
env:
53+
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
54+
ISSUE_TITLE: '${{ github.event.issue.title }}'
55+
ISSUE_BODY: '${{ github.event.issue.body }}'
56+
ISSUE_NUMBER: '${{ github.event.issue.number }}'
57+
REPOSITORY: '${{ github.repository }}'
58+
with:
59+
gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}'
60+
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
61+
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
62+
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
63+
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
64+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
65+
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
66+
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
67+
settings: |-
68+
{
69+
"maxSessionTurns": 25,
70+
"coreTools": [
71+
"run_shell_command(echo)",
72+
"run_shell_command(gh label list)",
73+
"run_shell_command(gh issue edit)"
74+
],
75+
"telemetry": {
76+
"enabled": true,
77+
"target": "gcp"
78+
}
79+
}
80+
prompt: |-
81+
## Role
82+
83+
You are an issue triage assistant. Analyze the current GitHub issue
84+
and apply the most appropriate existing labels. Use the available
85+
tools to gather information; do not ask for information to be
86+
provided.
87+
88+
## Steps
89+
90+
1. Run: `gh label list` to get all available labels.
91+
2. Review the issue title and body provided in the environment
92+
variables: "${ISSUE_TITLE}" and "${ISSUE_BODY}".
93+
3. Classify issues by their kind (bug, enhancement, documentation,
94+
cleanup, etc) and their priority (p0, p1, p2, p3). Set the
95+
labels accoridng to the format `kind/*` and `priority/*` patterns.
96+
4. Apply the selected labels to this issue using:
97+
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"`
98+
5. If the "status/needs-triage" label is present, remove it using:
99+
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"`
100+
101+
## Guidelines
102+
103+
- Only use labels that already exist in the repository
104+
- Do not add comments or modify the issue content
105+
- Triage only the current issue
106+
- Assign all applicable labels based on the issue content
107+
- Reference all shell variables as "${VAR}" (with quotes and braces)
108+
109+
- name: 'Post Issue Triage Failure Comment'
110+
if: |-
111+
${{ failure() && steps.gemini_issue_triage.outcome == 'failure' }}
112+
uses: 'actions/github-script@v7'
113+
with:
114+
github-token: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
115+
script: |-
116+
github.rest.issues.createComment({
117+
owner: '${{ github.repository }}'.split('/')[0],
118+
repo: '${{ github.repository }}'.split('/')[1],
119+
issue_number: '${{ github.event.issue.number }}',
120+
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.'
121+
})
Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: '📋 Gemini Scheduled Issue Triage'
2+
3+
on:
4+
schedule:
5+
- cron: '0 * * * *' # Runs every hour
6+
workflow_dispatch:
7+
8+
concurrency:
9+
group: '${{ github.workflow }}'
10+
cancel-in-progress: true
11+
12+
defaults:
13+
run:
14+
shell: 'bash'
15+
16+
permissions:
17+
contents: 'read'
18+
id-token: 'write'
19+
issues: 'write'
20+
statuses: 'write'
21+
22+
jobs:
23+
triage-issues:
24+
timeout-minutes: 5
25+
runs-on: 'ubuntu-latest'
26+
27+
steps:
28+
- name: 'Checkout repository'
29+
uses: 'actions/checkout@v5'
30+
31+
- name: 'Find untriaged issues'
32+
id: 'find_issues'
33+
env:
34+
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
35+
GITHUB_REPOSITORY: '${{ github.repository }}'
36+
GITHUB_OUTPUT: '${{ github.output }}'
37+
run: |-
38+
set -euo pipefail
39+
40+
echo '🔍 Finding issues without labels...'
41+
NO_LABEL_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
42+
--search 'is:open is:issue no:label' --json number,title,body)"
43+
44+
echo '🏷️ Finding issues that need triage...'
45+
NEED_TRIAGE_ISSUES="$(gh issue list --repo "${GITHUB_REPOSITORY}" \
46+
--search 'is:open is:issue label:"status/needs-triage"' --json number,title,body)"
47+
48+
echo '🔄 Merging and deduplicating issues...'
49+
ISSUES="$(echo "${NO_LABEL_ISSUES}" "${NEED_TRIAGE_ISSUES}" | jq -c -s 'add | unique_by(.number)')"
50+
51+
echo '📝 Setting output for GitHub Actions...'
52+
echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}"
53+
54+
ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')"
55+
echo "✅ Found ${ISSUE_COUNT} issues to triage! 🎯"
56+
57+
- name: 'Run Gemini Issue Triage'
58+
if: |-
59+
${{ steps.find_issues.outputs.issues_to_triage != '[]' }}
60+
uses: './'
61+
id: 'gemini_issue_triage'
62+
env:
63+
GITHUB_TOKEN: '${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }}'
64+
ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}'
65+
REPOSITORY: '${{ github.repository }}'
66+
with:
67+
gemini_cli_version: '${{ vars.GEMINI_CLI_VERSION }}'
68+
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
69+
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
70+
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
71+
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
72+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
73+
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
74+
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
75+
settings: |-
76+
{
77+
"maxSessionTurns": 25,
78+
"coreTools": [
79+
"run_shell_command(echo)",
80+
"run_shell_command(gh label list)",
81+
"run_shell_command(gh issue edit)",
82+
"run_shell_command(gh issue list)"
83+
],
84+
"telemetry": {
85+
"enabled": true,
86+
"target": "gcp"
87+
}
88+
}
89+
prompt: |-
90+
## Role
91+
92+
You are an issue triage assistant. Analyze issues and apply
93+
appropriate labels. Use the available tools to gather information;
94+
do not ask for information to be provided.
95+
96+
## Steps
97+
98+
1. Run: `gh label list`
99+
2. Check environment variable: "${ISSUES_TO_TRIAGE}" (JSON array
100+
of issues)
101+
3. For each issue, apply labels:
102+
`gh issue edit "${ISSUE_NUMBER}" --add-label "label1,label2"`.
103+
If available, set labels that follow the `kind/*`, `area/*`,
104+
and `priority/*` patterns.
105+
4. For each issue, if the `status/needs-triage` label is present,
106+
remove it using:
107+
`gh issue edit "${ISSUE_NUMBER}" --remove-label "status/needs-triage"`
108+
109+
## Guidelines
110+
111+
- Only use existing repository labels
112+
- Do not add comments
113+
- Triage each issue independently
114+
- Reference all shell variables as "${VAR}" (with quotes and braces)

0 commit comments

Comments
 (0)