Add community PR issue check agentic workflow#66209
Conversation
|
This PR uses a traditional GitHub Actions workflow with shell scripts to parse issue references. Consider replacing it with a GitHub Agentic Workflow instead — a markdown file with YAML frontmatter that an AI coding agent interprets at runtime. This avoids brittle regex/grep logic and lets the agent reason about the PR body contextually. Here's the suggested replacement for ---
on:
pull_request:
types: [labeled]
names: [community-contribution]
forks: ["*"]
permissions:
contents: read
pull-requests: read
safe-outputs:
add-comment:
hide-older-comments: true
---
# Community PR Issue Check
You are reviewing pull request #${{ github.event.pull_request.number }} in the
`${{ github.repository }}` repository. This PR has been labeled
`community-contribution`.
Your task is to determine whether the PR body references a related GitHub issue
in this repository. This is required by the repository's contribution policy.
## Instructions
1. Read the body of PR #${{ github.event.pull_request.number }}.
2. Search the PR body for references to GitHub issues in this repository.
Valid formats include:
- Keyword-linked references such as `Fixes #123`, `Closes #123`,
`Resolves #123`, `Addresses #123`, or `Related to #123`
- Direct URL references such as
`https://github.com/${{ github.repository }}/issues/123`
- Plain `#123` references in context
3. For each candidate reference found, verify via the GitHub API that the
referenced number is an **issue** (not a pull request) in the
`${{ github.repository }}` repository.
4. Based on your findings:
**If at least one valid issue reference exists**, call the `noop` tool:
```
{"noop": {"message": "PR #<number> references issue #<issue>. No action needed."}}
```
**If NO valid issue reference exists**, use the `add_comment` tool to post a
comment on the triggering PR with the following content:
- Thank the contributor for their interest in contributing to ASP.NET Core.
- Explain that all community contributions are expected to have a
corresponding GitHub issue **before** a pull request is submitted. This
lets the team discuss the approach and ensure alignment with the project
roadmap before significant effort is invested.
- Link to the [Contributing Guide](https://github.com/dotnet/aspnetcore/blob/main/CONTRIBUTING.md)
and specifically reference:
- The **"Finding an issue to work on"** section — contributors should look
for issues labeled [`help wanted`](https://aka.ms/aspnet/helpwanted)
or [`good first issue`](https://aka.ms/aspnet/goodfirstissues).
- The **"Before submitting the pull request"** section — which states
contributors should _"find an existing issue with the 'help-wanted'
label or discuss with the team to agree on adding a new issue with that
label"_.
- Ask the contributor to either:
1. Edit the PR description to link an existing issue, or
2. Open a new issue first describing the problem or feature, then update
the PR description to reference it.
- Be welcoming and encouraging — community contributions are valued.
If no action is needed, you MUST call the `noop` tool with a message explaining why:
{"noop": {"message": "No action needed: [brief explanation]"}}Key differences from the current approach:
To deploy: install |
|
@copilot take a look at the comments |
Switched this over to an agentic workflow at
Addressed in 2a9a76a, with a follow-up cleanup in 8bbf667. Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
8bbf667 to
89f6aaa
Compare
|
@akoeplinger can you take a look? |
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Agentic Workflow to enforce the repo policy that community-contribution PRs should link an associated issue, by inspecting the PR body and posting guidance when no valid issue reference is found.
Changes:
- Introduces an agentic workflow prompt for checking whether a community PR references a valid issue in
dotnet/aspnetcore. - Configures safe outputs to either noop when an issue is present or add a guidance comment when missing.
| --- | ||
| on: | ||
| pull_request: | ||
| types: [labeled] | ||
| names: [community-contribution] | ||
| forks: ["*"] |
There was a problem hiding this comment.
This workflow is only provided as a .md agentic workflow file, but the repo’s existing agentic workflows also commit a compiled *.lock.yml GitHub Actions workflow (generated via gh aw compile) that is what actually runs in Actions. Without adding a corresponding community-pr-issue-check.lock.yml, this workflow likely won’t execute at all.
| @@ -0,0 +1,76 @@ | |||
| --- | |||
| on: | |||
| pull_request: | |||
There was a problem hiding this comment.
Triggering on pull_request for community contributions (often from forks) typically yields a read-only GITHUB_TOKEN, which can prevent posting the required guidance comment. In this repo, workflows that need to label/comment on fork PRs use pull_request_target; consider switching to pull_request_target here so add-comment can reliably post to the PR.
| pull_request: | |
| pull_request_target: |
| on: | ||
| pull_request: | ||
| types: [labeled] | ||
| names: [community-contribution] | ||
| forks: ["*"] |
There was a problem hiding this comment.
As written, this only runs on the labeled activity. If the PR template comment is posted and the author later edits the PR body to add a valid issue reference, the workflow won’t re-check (so it can’t emit noop or hide/replace the prior guidance comment) unless the label is toggled. Consider also running on edited (and gating on presence of the community-contribution label) so the check self-heals when the PR description is updated.
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/96d70a70-24ba-4491-a8e0-96dec70cbe41 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/70d93a13-943e-4423-ab99-077728c56542 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/aspnetcore/sessions/70d93a13-943e-4423-ab99-077728c56542 Co-authored-by: javiercn <6995051+javiercn@users.noreply.github.com>
89f6aaa to
33454e6
Compare
| - https://github.com/${{ github.repository }}/blob/${{ github.event.pull_request.base.ref }}/CONTRIBUTING.md | ||
| - https://github.com/${{ github.repository }}/blob/${{ github.event.pull_request.base.ref }}/.github/pull_request_template.md |
There was a problem hiding this comment.
maybe we should just link to main here
Add community PR issue check agentic workflow
Add an agentic workflow for community PR issue checks
Description
This PR adds a community PR issue check for
dotnet/aspnetcore, but updates the implementation based on review feedback to use a GitHub Agentic Workflow instead of a traditional shell-based GitHub Actions workflow.Changes included:
.github/workflows/community-pr-issue-check.md.github/workflows/community-pr-issue-check.ymlcommunity-contributionnoopwhen a valid issue reference is already presentadd-commentto post contribution-policy guidance when no qualifying issue is linkedThe scope remains focused on enforcing the repository policy that community contribution PRs should have an associated issue before review, but the implementation now aligns with the repository’s existing agentic workflow pattern.
Original prompt
User: Research https://docs.github.com/en/actions/how-tos/write-workflows to create a workflow that reviews new opened PRs, determines if they are community contributions, and checks if they have associated issues. Our goal is to enforce the contribution policy that we have on the repo, where issues need to be opened before PRs for taking contributions. Research also on #github in dotnet/aspnetcore the details
GitHub Copilot: Created 4 todos
Fetched https://docs.github.com/en/actions/how-tos/write-workflows
Let me dig deeper into the workflow syntax and the dotnet/aspnetcore contribution policies.
Ran Get file or directory contents
Completed with input: {
"owner": "dotnet",
"repo": "aspnetcore",
"path": ".github/workflows"
}
Fetched https://docs.github.com/en/actions/how-tos/write-workflows/choose-when-workflows-run/events-that-trigger-workflows
Fetched https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions
Now let me look at the aspnetcore contribution policy and the teams file to understand how they identify community contributors vs team members.
Starting: Research dotnet/aspnetcore PR policies (2/4)
Ran Get file or directory contents
Completed with input: {
"owner": "dotnet",
"path": "CONTRIBUTING.md",
"repo": "aspnetcore"
}
Ran Get file or directory contents
Completed with input: {
"owner": "dotnet",
"path": ".github/PULL_REQUEST_TEMPLATE.md",
"repo": "aspnetcore"
}
Ran Get file or directory contents
Completed with input: {
"owner": "dotnet",
"path": ".github",
"repo": "aspnetcore"
}
Ran Get file or directory contents
Completed with input: {
"owner": "dotnet",
"path": ".github/pull_request_template.md",
"repo": "aspnetcore"
}
Ran Get file or directory contents
Completed with input: {
"owner": "dotnet",
"path": ".github/PULL_REQUEST_TEMPLATE",
"repo": "aspnetcore"
}
Fetched 2 resources
Starting: Create the PR review workflow (4/4)
Here's a summary of my research findings, followed by the workflow I've created:
Research Findings
GitHub Actions Workflow Mechanics
pull_request_targetis the right event trigger. Unlikepull_request, it runs in the context of the base branch and grants theGITHUB_TOKENread/write permissions even for PRs from forks. This is essential because community PRs come from forks, and the standardpull_requestevent gives only read-only tokens for fork PRs.pull_request_target, you must never checkout the PR's head code and execute it, as that opens a script injection vector. This workflow only reads PR metadata (author, body), so it's safe.permissionskey to onlypull-requests: write(for commenting).dotnet/aspnetcore Contribution Policy
From
CONTRIBUTING.mdand the PR template:help wantedorgood first issue) or open a new issue before submitting a PR.Fixes #<number>format.mcp_github_add_comment_to_pending_reviewToolThis tool adds a file/line-level review comment to an already-existing pending review. Key details:
owner,repo,pullNumber,path,body,subjectType(FILE or LINE)line,side(LEFT/RIGHT),startLine,startSide(for multi-line comments)mcp_github_add_issue_commentwhich adds a top-level conversation comment (used for general PR comments, not inline code review).Workflow
Here's the workflow implementing the contribution policy check:
Analyzing your answers...
Here's the complete workflow for
dotnet/aspnetcore: