Skip to content

Configure PR auto-close after 2 weeks of inactivity - #6336

Merged
JeffreyCA merged 2 commits into
mainfrom
copilot/configure-auto-close-prs
Dec 9, 2025
Merged

Configure PR auto-close after 2 weeks of inactivity#6336
JeffreyCA merged 2 commits into
mainfrom
copilot/configure-auto-close-prs

Conversation

Copilot AI commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

Configures GitHub resource management policy to auto-close stale PRs after 2 weeks, with warning at 1 week.

Changes

  • Warning threshold: 60 days → 7 days before applying no-recent-activity label
  • Check frequency: Weekly (Friday 5am) → Hourly (6am) for consistent monitoring
  • Close behavior: Unchanged at 7 days after warning (14 days total)

Timeline

Event Days Action
No activity 7 Add no-recent-activity label + warning comment
Still no activity 14 Auto-close PR

Authors can reopen by commenting /reopen or pushing new commits (removes label and resets timer).

Original prompt

This section details on the original issue you should resolve

<issue_title>Auto close PRs > 2 weeks without activity</issue_title>
<issue_description>The https://github.com/Azure/azure-dev/blob/main/.github/policies/resourceManagement.yml file is responsible for controlling this.

Configure to auto close PRs > 2 weeks without activity, with a warning at the 1 week mark.</issue_description>

<agent_instructions>Documentation:

# Automated PR Triage Example

This is a real-world, though simplified, example of how you can use the Resource Management Policy to
automate the triage process for Pull Requests. This process will use `eventResponderTasks` to label
PR's and provide feedback to the author based on specific criteria. It will then use `scheduledTasks` to
eventually close the PR if the author does not respond to the feedback.

## Provide Author Feedback

The first part of this process uses the `eventResponderTasks` to detect and respond to different
scenarios happening within the PR. If it finds a match to a scenario, it adds a comment in the PR
for the author and then adds the `Needs-Author-Feedback` label. This label will be the key to future
`scheduledSearches` to close the PR if the feedback is not addressed.

```yml
name: PR Triage
description: PR Triage Process
resource: repository

configuration:
  resourceManagementConfiguration:
    eventResponderTasks:
    - description: Detect changes to Pipelines by unauthorized users
      if:
      - payloadType: Pull_Request
      - filesMatchPattern:
          pattern: DevOpsPipelineDefinitions/*
      - or:
        - activitySenderHasPermission:
            permission: Read
        - activitySenderHasPermission:
            permission: None
      then:
      - addReply:
          reply: >-
            Hello @${issueAuthor},


            Sorry we cannot process ${number} because you are changing validation-pipeline.yaml. Please remove that file from your PR. If you would like to discuss changes to validation-pipeline.yml, please file an issue.


            Template: msftbot/pipelineModified
      - assignTo:
          users:
          - PR Author
      - addLabel:
          label: Needs-Author-Feedback

    - description: PR validation adds label about Manifest Validation Error
      triggerOnOwnActions: false
      if:
      - payloadType: Pull_Request
      - or:
        - labelAdded:
            label: Manifest-Validation-Error
      then:
      - addReply:
          reply: >-
            Hello @${issueAuthor},


            The package manager bot determined that the metadata was not compliant.


            Please verify the manifest file is compliant with the package manager [1.4 manifest specification](https://github.com/microsoft/winget-pkgs/tree/master/doc/manifest/schema/1.4.0).

            Make sure the ID is of the form publisher.appname and that the folder structure is manifests\partition\publisher\appname\version.

            Note: The path and "PackageIdentifier" are case sensitive.


            Be sure to use a tool like [VSCode](https://code.visualstudio.com/) to make sure the manifest YAML syntax is correct.


            You could also try our [Windows Package Manager Manifest Creator](https://github.com/microsoft/winget-create) or the [YamlCreate script](https://github.com/microsoft/winget-pkgs/blob/master/doc/tools/YamlCreate.md).


            For details on the specific error, see the details link below in the build pipeline.


            Template: msftbot/validationError/manifest/metadata
      - assignTo:
          users:
          - PR Author
      - addLabel:
          label: Needs-Author-Feedback

    - description: Clear labels when PR is updated
      triggerOnOwnActions: false
      if:
      - payloadType: Pull_Request
      - or:
        - isAction:
            action: Synchronize
      then:
      - removeLabel:
          label: Manifest-Validation-Error
      - removeLabel:
          label: Blocking-Issue
      - removeLabel:
          label: Needs-Attention
      - removeLabel:
          label: Needs-Author-Feedback

          
    - description: Clear labels when comment is added
      triggerOnOwnActions: false
      if:
      - payloadType: Issue_Comment
      - or:
        - commentContains:
            pattern: '\/[a|A][z|Z][p|P] [r|R][u|U][n|N]'
            isRegex: True
        - commentContains:
            pattern: '\/[a|A][z|Z][u|U][r|R][e|E][p|P][i|I][p|P][e|E][l|L][i|I][n|N][e|E][s|S] [r|R][u|U][n|N]'
            isRegex: True
      - not:
          isActivitySender:
            user: microsoft-github-policy-service[bot]
            issueAuthor: False
      - or:
        - activitySenderHasPermission:
            permission: Admin
        - activitySenderHasPermission:
            permission: Write
      then:
      - removeLabel:
          label: Manifest-Validation-Error
      - removeLabel:
          label: Blocking-Issue
      - removeLabel:
          label: Needs-Attention
      ...

</details>



<!-- START COPILOT CODING AGENT SUFFIX -->

- Fixes Azure/azure-dev#6335

<!-- START COPILOT CODING AGENT TIPS -->
---

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more [Copilot coding agent tips](https://gh.io/copilot-coding-agent-tips) in the docs.

Co-authored-by: JeffreyCA <9157833+JeffreyCA@users.noreply.github.com>
Copilot AI changed the title [WIP] Configure auto close for inactive PRs after two weeks Configure PR auto-close after 2 weeks of inactivity Dec 9, 2025
Copilot AI requested a review from JeffreyCA December 9, 2025 19:36
@JeffreyCA
JeffreyCA marked this pull request as ready for review December 9, 2025 19:47

@vhvb1989 vhvb1989 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🔥

@JeffreyCA
JeffreyCA enabled auto-merge (squash) December 9, 2025 21:12
@JeffreyCA

Copy link
Copy Markdown
Contributor

/check-enforcer override

@JeffreyCA
JeffreyCA merged commit 4170334 into main Dec 9, 2025
5 checks passed
@JeffreyCA
JeffreyCA deleted the copilot/configure-auto-close-prs branch December 9, 2025 21:13
@JeffreyCA JeffreyCA linked an issue Dec 9, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Auto close PRs > 2 weeks without activity

3 participants