palantir / policy-bot

A GitHub App that enforces approval policies on pull requests
Apache License 2.0
777 stars 108 forks source link

can I have approval rule with has_author_in but in not form #840

Open MahmoudMabrok opened 2 months ago

MahmoudMabrok commented 2 months ago

Can we have something like not_has_author_in so rule is not needed as long as author not in list I provide.

the case I have :

if pr is by dev team, so need two approval one from dev team and one from admin team, but if author is admin , we need admin team approval only.

bluekeyes commented 2 months ago

Could you share an example of the policy you'd write if this predicate existed? I think it should be possible to implement what you described with existing features:

policy:
  approval:
    - dev changes are approved by dev
    - dev changes are approved by admin
    - admin changes are approved by admin

approval_rules:
  - name: dev changes are approved by dev
    if:
      has_author_in:
        teams: ["org/dev-team"]
    requires:
      count: 1
      teams: ["org/dev-team"]

  - name: dev changes are approved by admin
    if:
      has_author_in:
        teams: ["org/dev-team"]
    requires:
      count: 1
      teams: ["org/admin-team"]

  - name: admin changes are approved by admin
    if:
      has_author_in:
        teams: ["org/admin-team"]
    requires:
      count: 1
      teams: ["org/admin-team"]