Understanding rule structure and behavior
ruleset: - name: "Rule Name" when: - "event1" - "event2" if: - type: "condition1" # condition parameters - type: "condition2" # condition parameters validate: - type: "validation1" # validation parameters - type: "validation2" # validation parameters on_success: - action1: # action parameters - action2: # action parameters on_failure: - action3: # action parameters - action4: # action parameters
when
if
validate
on_success
on_failure
ruleset: - name: "Title Format Check" when: - "pull_request.opened" - "pull_request.edited" validate: - type: "title" match: "^(feat|fix|docs): .+" on_failure: - comment: body: "PR title should start with 'feat:', 'fix:', or 'docs:'"
ruleset: - name: "Backend Tests Required" when: - "pull_request.opened" - "pull_request.synchronize" if: - type: "files" modified: match: "src/backend/.+\\.js$" validate: - type: "files" modified: match: "tests/backend/.+\\.test.js$" on_failure: - comment: body: "Backend changes require corresponding test files"
ruleset: - name: "Production Code Review" when: - "pull_request.opened" - "pull_request.ready_for_review" if: - type: "branch" base: match: "main" - type: "label" match: "production" validate: - type: "size" files: 20 - type: "approvals" count: min: 2 require_code_owners: true on_success: - label: add: ["ready-for-merge"] on_failure: - comment: body: | This PR targets the production branch and requires: - No more than 20 files changed - At least 2 approvals including code owners {{ validation_summary }}