Skip to content

Conversation

Copy link

Copilot AI commented Oct 15, 2025

Summary

This PR implements an automated workflow to ensure that only PowerShell team members with maintainer rights can create issues in the Announcements repository, aligning with the repository's stated purpose as an announcements-only space.

Problem

The Announcements repository is explicitly intended for team announcements only, as stated in the README:

This repo is for team announcements only. To file a bug or start a discussion, please find the appropriate repo in PowerShell and create a new issue.

However, there was no automated enforcement to prevent non-maintainers from opening issues, requiring manual intervention to close inappropriate issues.

Solution

Added a GitHub Actions workflow (.github/workflows/close-non-maintainer-issues.yml) that:

  1. Triggers automatically when any issue is opened
  2. Checks permissions using the GitHub API to determine if the issue author has admin, write, or maintain access to the repository
  3. Auto-closes issues from users without maintainer rights, posting a helpful comment that:
    • Explains why the issue was closed
    • Directs users to appropriate PowerShell repositories for bugs and discussions
    • References the main PowerShell/PowerShell repository for general issues

Implementation Details

The workflow uses the actions/github-script@v7 action to:

  • Query the collaborator permission level via github.rest.repos.getCollaboratorPermissionLevel()
  • Check if the user has admin, write, or maintain permissions
  • If not, add a comment and close the issue using the GitHub REST API

Error handling ensures that if permission checks fail (e.g., for external users not in the collaborator list), the workflow assumes no access and closes the issue.

Benefits

  • Reduces manual effort - No longer requires maintainers to manually close inappropriate issues
  • Provides immediate feedback - Users instantly know they're in the wrong place with clear guidance
  • Maintains repository integrity - Ensures the Announcements repository stays focused on its intended purpose
  • User-friendly - Helpful message directs users to the correct location for their needs
Original prompt

Write a workflow that automatically closes issue opened by anyone without maintainer rights


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@xtqqczze
Copy link

xtqqczze commented Oct 15, 2025

Why not just limit the ability to create issues to users that are collaborators on this repository.

image

Copilot AI changed the title [WIP] Add workflow to automatically close issues by non-maintainers Add workflow to automatically close issues from non-maintainers Oct 15, 2025
Copilot AI requested a review from TravisEz13 October 15, 2025 21:05
Copilot finished work on behalf of TravisEz13 October 15, 2025 21:05
@TravisEz13
Copy link
Member

TravisEz13 commented Oct 15, 2025

Why not just limit the ability to create issues to users that are collaborators on this repository.

Good question, this is a temporary setting that can only be set for up to 6 months. @xtqqczze

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.

3 participants