Skip to content

Close Wrong Team by Directory

Close PRs to a specified directory if the PR author is not on an approved team.

Close Wrong Team by Directory

Configuration Description

Conditions (all must be true):

  • The PR changes one or more files inside /src/views. Customize this value for your project.
  • The PR author is not a member of the ui team. Customize this value for your organization.

Automation Actions:

  • Close the PR.
  • Post a comment that explains why the PR was closed.

Close Wrong Team by Directory

# -*- mode: yaml -*-
manifest:
  version: 1.0

automations:
  # Close PRs to restricted sections of the codebase if the PR author isn't on the correct team. 
  close_wrong_team_by_directory:
    # Triggered when someone who isn't on the `ui` team submits a PR to change files inside /src/views
    if:
      - {{ files | match(regex=r/src\/views/) | some }}
      - {{ pr.author_teams | match(term='ui') | nope }}
    # Close the PR and post a comment explaining the next step.
    run:
      - action: add-comment@v1
        args: 
          comment: Please contact a member of the `ui` team if you need to make changes to files in `src/views`
      - action: close@v1

Additional Resources

gitStream is a workflow automation tool that enables you to use YAML configuration files to optimize your code review process. Add context to PRs, find code experts for reviews, and automate the merge process to maximize developer productivity.

Learn More about how gitStream Works.

Related Automations:

More Automations can be found on the Automation Library and Integrations pages.