mergeable
mergeable copied to clipboard
Multi-branch check using multiple operators
Hello,
I was wondering how I could achieve checking against multiple branch patterns using baseRef and headRef to ensure our team is following the branching policy we have as our development workflow. I've attempted the following but it doesn't seem to register it as a check and therefore nothing runs:
- when: pull_request.*, pull_request_review.*
name: 'Branch Compliance'
validate:
- do: or
validate:
- do: baseRef
must_include:
regex: '^(main|master)$'
- do: headRef
must_include:
regex: '^hotfix/[a-z]{2}/[a-z0-9._-]+$'
- do: or
validate:
- do: baseRef
must_include:
regex: '^(feature|amend|update|fix|refactor)/[a-z0-9._-]+$'
- do: headRef
must_include:
regex: '^task/[a-z]{2}/[a-z0-9._-]+$'
- do: or
validate:
- do: baseRef
must_include:
regex: '^task/[a-z]{2}/[a-z0-9._-]+$'
- do: headRef
must_include:
regex: '^task/[a-z]{2}/[a-z0-9._-]+$'
Trying it on an individual rule worked:
- when: pull_request.*, pull_request_review.*
name: 'Branch Compliance'
validate:
- do: baseRef
must_include:
regex: '^(main|master)$'
- do: headRef
must_include:
regex: '^hotfix/[a-z]{2}/[a-z0-9._-]+$'
but this isn't ideal as it needs to check at least one of the patterns is valid to pass, not all of them.