Skip to content

Add PR Needs-Author-Feedback lifecycle workflow#48812

Closed
MuyuanMS wants to merge 16 commits into
mainfrom
issue/5074-pr-needs-author-feedback-workflow
Closed

Add PR Needs-Author-Feedback lifecycle workflow#48812
MuyuanMS wants to merge 16 commits into
mainfrom
issue/5074-pr-needs-author-feedback-workflow

Conversation

@MuyuanMS

@MuyuanMS MuyuanMS commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a GitHub Actions workflow that manages the "Needs-Author-Feedback" label lifecycle for pull requests, complementing the existing fabricbot-based issue management.

This addresses the problem of community PRs going stale while pending author response — currently fabricbot handles stale issues but not PRs.

Behavior

Flow diagram

┌──────────────────────────────────────────────────────────────────────┐
│  Maintainer adds "Needs-Author-Feedback" label (or /needinfo)        │
└──────────────────────────────────────────────────────────────────────┘
         │
         ▼
┌─────────────────────────────────┐     ┌─────────────────────────────┐
│  7 days, no author activity     │────►│  Convert PR to draft        │
│                                 │     │  + post warning comment     │
└─────────────────────────────────┘     └─────────────────────────────┘
         │                                           │
         ▼                                           ▼
┌─────────────────────────────────┐     ┌─────────────────────────────┐
│  14 days total, still inactive  │────►│  Close PR                   │
│                                 │     │  + post closing comment     │
└─────────────────────────────────┘     └─────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────┐
│  Author pushes commits                                               │
└──────────────────────────────────────────────────────────────────────┘
         │
         ▼
    Remove "Needs-Author-Feedback"

┌──────────────────────────────────────────────────────────────────────┐
│  Author comments or submits review                                   │
└──────────────────────────────────────────────────────────────────────┘
         │
         ▼
    Remove "Needs-Author-Feedback" (handled by existing fabricbot)

Jobs

Job Trigger Action
author-responded-push Author pushes commits (synchronize) Removes Needs-Author-Feedback
check-stale-prs Cron schedule (every 6 hours) or workflow_dispatch Converts to draft at 7 days / closes at 14 days of author inactivity

Why not extend fabricbot (resourceManagement.yml)?

The existing fabricbot policy handles issues with Needs-Author-Feedback (5d stale → 10d close) and already removes the label on author comments for both issues and PRs. However, fabricbot cannot:

  • Detect push (synchronize) events on PRs
  • Call GraphQL mutations (convertPullRequestToDraft)
  • Implement conditional logic (already-draft vs not-draft)
  • Filter scheduled searches by isPullRequest (only isIssue exists)

This workflow adds only what fabricbot can't do — avoiding duplication.

Inactivity detection

  • Measures inactivity from the later of the label-applied timestamp or the author's last activity — so labeling an already-stale PR starts a fresh 7-day window rather than triggering immediately.
  • Author activity = last commit by the PR author + last issue/review comment by the author (ignoring bot comments).
  • Uses issues.listEvents to find when the label was most recently applied, handling label re-application cycles correctly.

Edge cases handled

  • PR already draft when label is added: Posts the 7-day warning on first detection, then closes after 7 more days of inactivity.
  • Draft conversion: Uses GraphQL convertPullRequestToDraft mutation since REST API doesn't support this.
  • Draft conversion failure: Falls back to closing the PR if the GraphQL mutation fails and 14 days have elapsed.
  • Label re-application: Bot warning detection filters by created_at >= labelAppliedDate so prior cycle's warnings are ignored.
  • Concurrency: Uses a per-PR concurrency group to prevent duplicate runs; scheduled runs share a stable 'maintenance' group.
  • Race conditions: Re-checks label presence before every mutation (guards against concurrent removal by maintainer).
  • Manual testing: workflow_dispatch trigger with dry_run input allows safe testing without making changes.

Triggers summary

Event Purpose
pull_request_target: [synchronize] Author push detection (fabricbot can't detect this)
schedule (every 6h) Stale PR processing
workflow_dispatch Manual runs with dry-run option

Relationship to existing automation

Mechanism Scope What it handles
resourceManagement.yml (fabricbot) Issues + PR comments Removes Needs-Author-Feedback on author comment; stale close for issues only
This workflow PRs only Removes label on author push; 7d→draft, 14d→close lifecycle

No overlap — fabricbot handles comment-based label removal, this workflow handles push-based removal and the stale lifecycle.

Testing

  • YAML syntax validated
  • Workflow tested end-to-end on fork
  • Verified: author-push label removal ✅, dry-run scheduled job ✅
  • Workflow logic is idempotent (safe to run multiple times on the same PR)
  • No label is added/removed if already in the expected state

Adds a GitHub Actions workflow that manages the Needs-Author-Feedback
label lifecycle for pull requests:

- New non-draft PRs automatically receive the Needs-Triage label
- When author pushes commits or comments, Needs-Author-Feedback is
  removed and Needs-Triage is re-added
- After 7 days of inactivity, PR is converted to draft with a warning
- After 14 days of inactivity, PR is closed with a clear message

This complements the existing fabricbot-based issue management in
resourceManagement.yml by adding PR-specific behaviors (draft conversion)
that require GitHub Actions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new GitHub Actions workflow to automate the Needs-Author-Feedback label lifecycle for pull requests, including auto-triage labeling, automatic label swaps when the author responds, and scheduled stale handling (draft conversion + eventual close).

Changes:

  • Introduces .github/workflows/pr-needs-author-feedback.yml to apply Needs-Triage on new non-draft PRs.
  • Automatically removes Needs-Author-Feedback (and re-adds Needs-Triage) when the PR author pushes commits or comments.
  • Adds a scheduled stale check intended to convert inactive PRs to draft after 7 days and close them after 14 days (based on author activity).

Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
…nation

- Fix: close only after 14 days of author inactivity (not 7 days after
  draft conversion). The previous logic closed on the next 6h cycle after
  converting to draft.
- Fix: filter commits by author login so maintainer pushes don't reset the
  inactivity timer.
- Fix: use paginate() for both listComments and listCommits to handle PRs
  with >100 items.
- Fix: only post the draft-conversion comment if the GraphQL mutation
  actually succeeded.
- Bump actions/github-script from v7 to v9 for consistency with the rest
  of the repo.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 3 comments.

Comment thread .github/workflows/pr-needs-author-feedback.yml
Comment thread .github/workflows/pr-needs-author-feedback.yml
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
- Add concurrency guard to prevent overlapping runs from racing on the
  same PR (consistent with auto-labeler.yml pattern).
- Add pull_request_review trigger so author review submissions also
  remove the Needs-Author-Feedback label.
- Include PR review comments (pulls.listReviewComments) in the scheduled
  inactivity check, not just issue comments.
- Use the label-applied timestamp as inactivity baseline: timer starts
  from max(label_applied_date, last_author_activity), so labeling a
  long-stale PR gives the author a fresh 7-day window.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 5 comments.

Comment thread .github/workflows/pr-needs-author-feedback.yml
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml
…wording, fallback

- Use stable concurrency group ('maintenance') for schedule/dispatch runs
  so only one maintenance run is active at a time.
- Add open-state check for pull_request_review trigger to avoid mutating
  labels on closed PRs.
- Bot warning detection now requires the comment timestamp >= label-applied
  date, so label remove/re-apply cycles don't reuse stale warnings.
- Already-draft PRs get accurate wording ('This draft pull request has been
  marked as requiring author feedback...') instead of falsely claiming
  conversion.
- If GraphQL convertPullRequestToDraft fails and inactivity >= 14 days,
  close the PR as a fallback instead of leaving it open indefinitely.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Comment thread .github/workflows/pr-needs-author-feedback.yml Outdated
Extends the workflow to handle 'Add single comment' on diffs
(pull_request_review_comment events). Without this, inline review
comments from the author were counted as activity by the scheduled
job but did not remove the Needs-Author-Feedback label in real time.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

The previous marker phrase spanned a line break in the join()'d comment
body, so it never matched the conversion comment. Use the shorter
'requiring author feedback' which appears on a single line in both the
auto-conversion comment and the already-draft warning comment.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.

Comment thread .github/workflows/pr-needs-author-feedback.yml
Comment thread .github/workflows/pr-needs-author-feedback.yml
- Skip expensive API pagination for PRs labeled < 7 days ago (can never
  meet draft/close threshold)
- Re-check that Needs-Author-Feedback label is still present before
  converting to draft or closing (guards against race with concurrent
  label removal)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up labels Jun 25, 2026
@michaeljolley

Copy link
Copy Markdown
Contributor

As for the reason for the new process, need info flow help adds the [Needs-Author-Feedback] label, but there's no periodical job closing it for PRs (current is issue only), so we need to have one for the PR.

The needinfo flow also is a fabricbot policy, which has no GraphQL support and no conditional logic, which isn't enough for PR handling like checking whether it's draft. That's why this workflow as a GitHub Action is added just for checking and closing PRs with the label.

I may have been unclear. I don't mind that it's a GitHub action. My question was why not use the same process that FabricBot does for issues?

  • We use /needinfo in a PR and it adds the Needs-Author-Feedback label.
  • Response from OP removes Needs-Author-Feedback and adds Needs-Team-Response.
  • On an scheduled run, with the Needs-Author-Feedback label, after n days/weeks close it.

@MuyuanMS

MuyuanMS commented Jun 26, 2026

Copy link
Copy Markdown
Contributor Author

As for the reason for the new process, need info flow help adds the [Needs-Author-Feedback] label, but there's no periodical job closing it for PRs (current is issue only), so we need to have one for the PR.
The needinfo flow also is a fabricbot policy, which has no GraphQL support and no conditional logic, which isn't enough for PR handling like checking whether it's draft. That's why this workflow as a GitHub Action is added just for checking and closing PRs with the label.

I may have been unclear. I don't mind that it's a GitHub action. My question was why not use the same process that FabricBot does for issues?

  • We use /needinfo in a PR and it adds the Needs-Author-Feedback label.
  • Response from OP removes Needs-Author-Feedback and adds Needs-Team-Response.
  • On an scheduled run, with the Needs-Author-Feedback label, after n days/weeks close it.

@michaeljolley This PR aims to achieve the third bullet point, and part of second bullet point to make existing needinfo workflow works for PRs as well:
When OP commits, it also removes Needs-Author-Feedback (for PR only)
PR has a scheduled run to check for the label after n days/weeks to convert to draft or close it

All other parts are handled by existing logic.

Existing fabricbot policy has limitations in logics like checking whether it's draft, so I used GitHub Action to complete the workflow

@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up labels Jun 26, 2026
@MuyuanMS MuyuanMS removed the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jun 30, 2026
@microsoft-github-policy-service microsoft-github-policy-service Bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Jul 1, 2026
@MuyuanMS

MuyuanMS commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

As for the reason for the new process, need info flow help adds the [Needs-Author-Feedback] label, but there's no periodical job closing it for PRs (current is issue only), so we need to have one for the PR.
The needinfo flow also is a fabricbot policy, which has no GraphQL support and no conditional logic, which isn't enough for PR handling like checking whether it's draft. That's why this workflow as a GitHub Action is added just for checking and closing PRs with the label.

I may have been unclear. I don't mind that it's a GitHub action. My question was why not use the same process that FabricBot does for issues?

  • We use /needinfo in a PR and it adds the Needs-Author-Feedback label.
  • Response from OP removes Needs-Author-Feedback and adds Needs-Team-Response.
  • On an scheduled run, with the Needs-Author-Feedback label, after n days/weeks close it.

@michaeljolley This PR aims to achieve the third bullet point, and part of second bullet point to make existing needinfo workflow works for PRs as well: When OP commits, it also removes Needs-Author-Feedback (for PR only) PR has a scheduled run to check for the label after n days/weeks to convert to draft or close it

All other parts are handled by existing logic.

Existing fabricbot policy has limitations in logics like checking whether it's draft, so I used GitHub Action to complete the workflow

@michaeljolley created #49151 where I leverage existing fabricbot policy - meaning that we no longer can convert to draft but to close directly due to limitations. If you think that's more like the way to go, then I'll close this one

@microsoft-github-policy-service microsoft-github-policy-service Bot added Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something Needs-Triage For issues raised to be triaged and prioritized by internal Microsoft teams Needs-Team-Response An issue author responded so the team needs to follow up labels Jul 7, 2026
@michaeljolley

Copy link
Copy Markdown
Contributor

Yeah. I vote close over draft for sure.

@niels9001 niels9001 closed this Jul 8, 2026
MuyuanMS added a commit that referenced this pull request Jul 9, 2026
…9151)

## Summary

Adds fabricbot rules to manage the `Needs-Author-Feedback` label
lifecycle for **pull requests**, complementing the existing issue
management rules in `resourceManagement.yml`.

This is a **simpler alternative** to the GitHub Actions workflow
approach (PR #48812), trading advanced features (draft conversion,
author-specific activity tracking) for zero-maintenance fabricbot
automation.

## Behavior

### Flow diagram

```
┌──────────────────────────────────────────────────────────────────────┐
│  Maintainer adds "Needs-Author-Feedback" label to a PR              │
└──────────────────────────────────────────────────────────────────────┘
         │
         ▼
┌─────────────────────────────────────┐     ┌──────────────────────────────────┐
│  7 days, no activity                │────►│  Add "Status-No recent activity" │
│                                     │     │  + post warning comment          │
└─────────────────────────────────────┘     └──────────────────────────────────┘
         │                                               │
         ▼                                               ▼
┌─────────────────────────────────────┐     ┌──────────────────────────────────┐
│  7 more days (14 total), no activity│────►│  Close PR + post closing comment │
└─────────────────────────────────────┘     └──────────────────────────────────┘

┌──────────────────────────────────────────────────────────────────────┐
│  Author pushes commits OR comments on PR (at any point)              │
└──────────────────────────────────────────────────────────────────────┘
         │
         ▼
    Remove "Needs-Author-Feedback" → Add "Needs-Triage"
    Remove "Status-No recent activity" (if present)
```

### Scheduled searches (every 6 hours)

| Condition | Action |
|-----------|--------|
| PR + `Needs-Author-Feedback` + 7 days inactive + no `Status-No recent
activity` | Add `Status-No recent activity` label + warning comment |
| PR + `Needs-Author-Feedback` + `Status-No recent activity` + 7 more
days inactive | Post closing comment + close PR |

### Event responders

| Trigger | Action |
|---------|--------|
| Author comments on PR (`Issue_Comment` + `issueAuthor`) | Remove
`Needs-Author-Feedback`, add `Needs-Triage` + `Needs-Team-Response` |
| Author pushes commits (`Pull_Request` + `Synchronize` + `issueAuthor`)
| Remove `Needs-Author-Feedback`, add `Needs-Triage` |
| Any PR update activity | Remove `Status-No recent activity` |

### Bot messages

**Warning (at 7 days):**
> This pull request has been automatically marked as stale because it
has been marked as requiring author feedback but has not had any
activity for **7 days**. It will be closed if no further activity occurs
**within 7 days of this comment**. To keep this PR active, please push
your changes or leave a comment.

**Closing (at 14 days):**
> This pull request has been automatically closed because it has been
marked as requiring author feedback but has not had any activity for
**14 days**. If you would like to continue working on this, please
reopen the PR and push your changes.

## Comparison with GitHub Actions workflow (PR #48812)

| Feature | This PR (fabricbot) | PR #48812 (Actions) |
|---------|-------------------|-------------------|
| Convert to draft at 7 days | ❌ Not supported | ✅ Via GraphQL |
| Close at 14 days | ✅ | ✅ |
| Author-specific activity tracking | ❌ Any activity resets timer | ✅
Only author activity counts |
| Bot comment resets timer | ⚠️ Yes (fabricbot limitation) | ✅ No
(filtered out) |
| Maintenance burden | None (fabricbot managed) | Low (workflow file) |
| Testing before merge | ❌ No local testing | ✅ `workflow_dispatch` +
dry-run |
| Review comment detection | ❌ Only issue comments | ✅ Reviews + inline
comments |

## Trade-offs

**Pros:**
- Zero maintenance — fabricbot is a managed service
- Consistent with existing issue management patterns in the same file
- No workflow YAML to debug or maintain

**Cons:**
- No draft conversion (fabricbot cannot call GraphQL)
- `noActivitySince` counts **all** activity — bot comments, maintainer
comments, and label changes all reset the inactivity timer
- Cannot distinguish author activity from other activity
- No way to test locally or with dry-run before merge

## Relationship to existing automation

Mirrors the existing issue rules (lines 11-43) which use the same
pattern:
- Issues: 5 days → warning, 5 more days → close
- PRs (this change): 7 days → warning, 7 more days → close

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants