-
Notifications
You must be signed in to change notification settings - Fork 4
Add issue-triage-pr workflow with ability to make PRs #169
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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,31 @@ | ||
| # Issue Triage (with PR) | ||
|
|
||
| Investigate new issues and provide actionable triage analysis. For straightforward fixes, implement and open a draft PR. | ||
|
|
||
| ## Quick Install | ||
|
|
||
| ```bash | ||
| mkdir -p .github/workflows && curl -sL \ | ||
| https://raw.githubusercontent.com/elastic/ai-github-actions/v0/gh-agent-workflows/issue-triage-pr/example.yml \ | ||
| -o .github/workflows/issue-triage-pr.yml | ||
| ``` | ||
|
|
||
| See [example.yml](example.yml) for the full workflow file. | ||
|
|
||
| ## Trigger | ||
|
|
||
| | Event | Types | | ||
| | --- | --- | | ||
| | `issues` | `opened` | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Input | Description | Required | Default | | ||
| | --- | --- | --- | --- | | ||
| | `additional-instructions` | Repo-specific instructions appended to the agent prompt | No | `""` | | ||
| | `setup-commands` | Shell commands run before the agent starts | No | `""` | | ||
|
|
||
| ## Safe Outputs | ||
|
|
||
| - `add-comment` — post triage analysis on the issue | ||
| - `create-pull-request` — open a draft PR when a verified fix is implemented |
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,16 @@ | ||
| name: Issue Triage (with PR) | ||
| on: | ||
| issues: | ||
| types: [opened] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| discussions: write | ||
| issues: write | ||
| pull-requests: write # required by gh-aw compiler for add-comment (github/gh-aw#16673) | ||
|
|
||
| jobs: | ||
| run: | ||
| uses: elastic/ai-github-actions/.github/workflows/gh-aw-issue-triage-pr.lock.yml@v0 | ||
| secrets: | ||
| COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }} | ||
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,134 @@ | ||
| --- | ||
| description: "Investigate new issues and provide actionable triage analysis with optional PR creation" | ||
| imports: | ||
| - gh-aw-fragments/elastic-tools.md | ||
| - gh-aw-fragments/runtime-setup.md | ||
| - gh-aw-fragments/formatting.md | ||
| - gh-aw-fragments/rigor.md | ||
| - gh-aw-fragments/mcp-pagination.md | ||
| - gh-aw-fragments/workflow-edit-guardrails.md | ||
| - gh-aw-fragments/messages-footer.md | ||
| - gh-aw-fragments/safe-output-add-comment.md | ||
| - gh-aw-fragments/safe-output-create-pr.md | ||
| engine: | ||
| id: copilot | ||
| model: gpt-5.3-codex | ||
| concurrency: | ||
| group: "gh-aw-copilot-issue-triage-pr-${{ github.event.issue.number }}" | ||
| on: | ||
| workflow_call: | ||
| inputs: | ||
| additional-instructions: | ||
| description: "Repo-specific instructions appended to the agent prompt" | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| setup-commands: | ||
| description: "Shell commands to run before the agent starts (dependency install, build, etc.)" | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| messages-footer: | ||
| description: "Footer appended to all agent comments and reviews" | ||
| type: string | ||
| required: false | ||
| default: "" | ||
| secrets: | ||
| COPILOT_GITHUB_TOKEN: | ||
| required: true | ||
| reaction: "eyes" | ||
| concurrency: | ||
| group: issue-triage-pr-${{ github.event.issue.number }} | ||
| cancel-in-progress: true | ||
| permissions: | ||
| contents: read | ||
| issues: read | ||
| pull-requests: read | ||
| tools: | ||
| github: | ||
| toolsets: [repos, issues, pull_requests, search] | ||
| bash: true | ||
| web-fetch: | ||
| network: | ||
| allowed: | ||
| - defaults | ||
| - github | ||
| - go | ||
| - node | ||
| - python | ||
| - ruby | ||
| strict: false | ||
| roles: [admin, maintainer, write] | ||
| bots: | ||
| - "github-actions[bot]" | ||
| timeout-minutes: 30 | ||
| steps: | ||
| - name: Repo-specific setup | ||
| if: ${{ inputs.setup-commands != '' }} | ||
| env: | ||
| SETUP_COMMANDS: ${{ inputs.setup-commands }} | ||
| run: eval "$SETUP_COMMANDS" | ||
| --- | ||
|
|
||
| # Issue Triage Agent (with PR) | ||
|
|
||
| Triage new issues in ${{ github.repository }} and provide actionable analysis with implementation plans. For straightforward fixes, implement and open a draft PR. | ||
|
|
||
| ## Context | ||
|
|
||
| - **Repository**: ${{ github.repository }} | ||
| - **Issue**: #${{ github.event.issue.number }} — ${{ github.event.issue.title }} | ||
|
|
||
| ## Constraints | ||
|
|
||
| - **CAN**: Read files, search code, run tests and commands, comment on the issue, and open a draft PR for straightforward fixes. | ||
| - This workflow is primarily for investigation and planning. Local file changes are for verification only unless you implement a fix. | ||
|
|
||
| ## Triage Process | ||
|
|
||
| Follow these steps in order. | ||
|
|
||
| ### Step 1: Gather Context | ||
|
|
||
| 1. Call `generate_agents_md` to get the repository's coding guidelines and conventions. If this fails, continue without it. | ||
| 2. Read key repository files (README, CONTRIBUTING, etc.) to understand the project. | ||
| 3. Search for related issues and PRs (open and closed) that may be relevant. Call `issue_read` with method `get` on the most relevant issues to understand prior discussion, decisions, and whether this is a duplicate. | ||
|
|
||
| ### Step 2: Investigate the Codebase | ||
|
|
||
| 1. Read the issue description carefully to understand the request or problem. | ||
| 2. Explore the relevant parts of the codebase using `grep` and file reading. | ||
| 3. Run tests or commands in the workspace to verify reported bugs when possible: | ||
| - Run existing tests to confirm reported behavior | ||
| - Execute scripts to understand current behavior | ||
| - Run linters or static analysis if relevant | ||
| - Write small test files to validate findings | ||
| - Always explain what you're testing and why, and include command output in your response | ||
| 4. If the required change is small, clear, and verifiable, implement it directly and run relevant validation. | ||
|
|
||
| ### Step 3: Formulate Response | ||
|
|
||
| Provide a response with the following sections. Be concise and actionable — no filler or praise. | ||
|
|
||
| **Always lead with a tl;dr** — your first sentence should be the most important takeaway. | ||
|
|
||
| **Sections:** | ||
|
|
||
| 1. **Recommendation** — A clear, specific recommendation for how to address the issue. If you cannot recommend a course of action, say so with a reason. "I don't know" is better than a wrong answer. | ||
|
|
||
| 2. **Findings** — Key facts from your investigation (related code, existing implementations, relevant issues/PRs). Use `<details>` tags for longer content. | ||
|
|
||
| 3. **Verification** — If you ran tests or commands, include the output. Use `<details>` tags. | ||
|
|
||
| 4. **Detailed Action Plan** — Step-by-step plan a developer could follow to implement the recommendation (or summary of implemented changes if you completed them). Reference specific files, functions, and line numbers. Use `<details>` tags. | ||
|
|
||
| 5. **Related Items** — Table of related issues, PRs, files, and web resources. | ||
|
|
||
| Use `<details>` and `<summary>` tags for sections that would otherwise make the response too long. Short responses don't need collapsible sections. Your performance is judged by how accurate your findings are — do the investigation required to have high confidence. "I don't know" or "I'm unable to recommend a course of action" is better than a wrong answer. | ||
|
|
||
| ### Step 4: Post Response | ||
|
|
||
| 1. Call `add_comment` with your triage response. | ||
| 2. If you implemented a valid fix with verification, call `create_pull_request` to open a draft PR. | ||
|
|
||
| ${{ inputs.additional-instructions }} |
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.
The example.yml file has
contents: readpermission, but workflows that create pull requests needcontents: writepermission to create branches. All other workflows that usecreate_pull_request(mention-in-issue, bug-exterminator, small-problem-fixer, etc.) havecontents: write. This permission is needed whenautomatic-prsis enabled.