refactor(workflows): separate issue triage into two workflows (#2746)
This commit is contained in:
parent
5c4c833ddd
commit
9794d329d3
|
@ -0,0 +1,77 @@
|
|||
name: Gemini Issue Triage
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, reopened]
|
||||
|
||||
jobs:
|
||||
triage-issue:
|
||||
timeout-minutes: 5
|
||||
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@v1
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
|
||||
- name: Run Gemini Issue Triage
|
||||
uses: google-gemini/gemini-cli-action@1efc0bac9e0b2da6c6cab95df513324d8dfc2a79
|
||||
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:
|
||||
version: main
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }}
|
||||
OTLP_GCP_SERVICE_ACCOUNT: ${{ secrets.OTLP_GCP_SERVICE_ACCOUNT }}
|
||||
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }}
|
||||
settings_json: |
|
||||
{
|
||||
"coreTools": [
|
||||
"run_shell_command(gh label list)",
|
||||
"run_shell_command(gh issue edit)",
|
||||
],
|
||||
}
|
||||
prompt: |
|
||||
You are an issue triage assistant for GitHub issues.
|
||||
Your task is to analyze the issue and apply appropriate labels from the repository's list of available labels.
|
||||
|
||||
**IMPORTANT: Your only action should be to apply labels. Do not post any comments or modify any code.**
|
||||
|
||||
**Triage Workflow:**
|
||||
|
||||
1. **Fetch Available Labels:**
|
||||
Execute: `gh label list`
|
||||
|
||||
2. **Get Issue Information:**
|
||||
The issue details are available in environment variables:
|
||||
- Repository: $REPOSITORY
|
||||
- Issue Number: $ISSUE_NUMBER
|
||||
- Issue Title: $ISSUE_TITLE
|
||||
- Issue Body: $ISSUE_BODY
|
||||
|
||||
3. **Analyze and Apply Labels:**
|
||||
Based on the issue title and body, determine appropriate labels and apply them using:
|
||||
`gh issue edit $ISSUE_NUMBER --add-label "label1,label2"`
|
||||
|
||||
**Guidelines:**
|
||||
- Only use labels that exist in the repository
|
||||
- Do not add comments to the issue
|
||||
- Common label patterns: kind/bug, kind/enhancement, kind/documentation, area/*, priority/*
|
|
@ -1,73 +0,0 @@
|
|||
name: Gemini Issue Triage
|
||||
|
||||
on:
|
||||
issues:
|
||||
types: [opened, reopened]
|
||||
|
||||
jobs:
|
||||
triage-issue:
|
||||
if: github.event_name == 'issues'
|
||||
permissions:
|
||||
contents: read
|
||||
issues: 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@v1
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
|
||||
- name: Run Gemini Issue Triage
|
||||
uses: google-gemini/gemini-cli-action@238438ee44e83c7f97a1a9bb61e62853cebe9767
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
with:
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
prompt: |
|
||||
You are an issue triage assistant for GitHub issues.
|
||||
Your task is to analyze the issue and apply appropriate labels from the repository's list of available labels.
|
||||
|
||||
**IMPORTANT: Your only action should be to apply labels. Do not post any comments or modify any code.**
|
||||
|
||||
**Triage Workflow:**
|
||||
|
||||
1. **Fetch Available Labels:**
|
||||
- Execute the following shell command to get the list of all labels in the repository:
|
||||
`gh label list`
|
||||
|
||||
2. **Analyze the Issue:**
|
||||
- Based on the issue title, body, and any comments, determine the most appropriate labels.
|
||||
- Always apply:
|
||||
- Kind of issue (e.g., `kind/bug`, `kind/enhancement`, `kind/documentation`)
|
||||
- Area of the codebase it affects (e.g., `area/core`, `area/ux`, `area/tools`)
|
||||
- Priority if possible (e.g., `priority/p1`, `priority/p2`).
|
||||
|
||||
3. **Apply Labels:**
|
||||
- Use the `gh` command-line tool to add the selected labels to the issue.
|
||||
- Example command: `gh issue edit ${{ github.event.issue.number }} --add-label "kind/bug,area/core"`
|
||||
- You can add multiple labels in a single command.
|
||||
|
||||
4. **Finalize:**
|
||||
- Remove the `status/need-triage` label if it exists, as the issue has been triaged.
|
||||
|
||||
**Guidelines:**
|
||||
- Only use labels that exist in the repository (from the `gh label list` command).
|
||||
- Do not add a comment to the issue.
|
||||
- If no labels seem appropriate, do not apply any.
|
||||
|
||||
**Issue Information:**
|
||||
- Repository: ${{ github.repository }}
|
||||
- Issue Number: ${{ github.event.issue.number }}
|
||||
- Issue Title: ${{ github.event.issue.title }}
|
||||
- Issue Body: ${{ github.event.issue.body }}
|
||||
- Comment (if any): ${{ github.event.comment.body }}
|
|
@ -0,0 +1,72 @@
|
|||
name: Gemini Scheduled Issue Triage
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 * * * *' # Runs every hour
|
||||
workflow_dispatch: {}
|
||||
|
||||
jobs:
|
||||
triage-issues:
|
||||
timeout-minutes: 10
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
issues: write
|
||||
steps:
|
||||
- name: Generate GitHub App Token
|
||||
id: generate_token
|
||||
uses: actions/create-github-app-token@v1
|
||||
with:
|
||||
app-id: ${{ secrets.APP_ID }}
|
||||
private-key: ${{ secrets.PRIVATE_KEY }}
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
token: ${{ steps.generate_token.outputs.token }}
|
||||
|
||||
- name: Find untriaged issues
|
||||
id: find_issues
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
run: |
|
||||
NO_LABEL_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue no:label" --json number,title,body)
|
||||
NEEDS_TRIAGE_ISSUES=$(gh issue list --repo ${{ github.repository }} --search "is:open is:issue label:\"status/needs-triage\"" --json number,title,body)
|
||||
ISSUES=$(echo "$NO_LABEL_ISSUES" "$NEEDS_TRIAGE_ISSUES" | jq -c -s 'add | unique_by(.number)')
|
||||
echo "issues_to_triage=$ISSUES" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Run Gemini Issue Triage
|
||||
if: steps.find_issues.outputs.issues_to_triage != '[]'
|
||||
uses: google-gemini/gemini-cli-action@1efc0bac9e0b2da6c6cab95df513324d8dfc2a79
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||
ISSUES_TO_TRIAGE: ${{ steps.find_issues.outputs.issues_to_triage }}
|
||||
REPOSITORY: ${{ github.repository }}
|
||||
with:
|
||||
version: main
|
||||
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
|
||||
OTLP_GCP_WIF_PROVIDER: ${{ secrets.OTLP_GCP_WIF_PROVIDER }}
|
||||
OTLP_GCP_SERVICE_ACCOUNT: ${{ secrets.OTLP_GCP_SERVICE_ACCOUNT }}
|
||||
OTLP_GOOGLE_CLOUD_PROJECT: ${{ secrets.OTLP_GOOGLE_CLOUD_PROJECT }}
|
||||
settings_json: |
|
||||
{
|
||||
"coreTools": [
|
||||
"run_shell_command(gh label list)",
|
||||
"run_shell_command(gh issue edit)",
|
||||
"run_shell_command(gh issue list)"
|
||||
],
|
||||
}
|
||||
prompt: |
|
||||
You are an issue triage assistant. Analyze issues and apply appropriate labels.
|
||||
|
||||
Steps:
|
||||
1. Run: `gh label list --limit 100`
|
||||
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"`
|
||||
|
||||
Guidelines:
|
||||
- Only use existing repository labels
|
||||
- Do not add comments
|
||||
- Triage each issue independently
|
||||
- Focus on: kind/*, area/*, priority/* labels
|
Loading…
Reference in New Issue