policy-bot icon indicating copy to clipboard operation
policy-bot copied to clipboard

can I have approval rule with has_author_in but in not form

Open MahmoudMabrok opened this issue 1 year ago • 2 comments

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 :

  • have a admin team
  • have dev team

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.

MahmoudMabrok avatar Sep 16 '24 08:09 MahmoudMabrok

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"]

bluekeyes avatar Sep 16 '24 22:09 bluekeyes

I too would like this feature but my use case is different. If the author is bot1 then ops team will approve it. If the author is anyone else let dev team handle it. This is to the same file.

Additionally I'd like the exact same scenario but for branches, but someone could make a branch pattern by accident. Perhaps negative matchers work for regex?

snuggie12 avatar Oct 10 '25 01:10 snuggie12