queue_rules:
  - name: urgent
    queue_conditions:
      - "label=C-urgent"
  - name: default
    queue_conditions:
      - "label!=C-urgent"
      - author!=dependabot[bot]
  - name: lowpriority
    queue_conditions:
      - author=dependabot[bot]

pull_request_rules:
  - name: Automatic merge on approval
    conditions:
      - and:
        - "#review-threads-unresolved=0"
        - "#approved-reviews-by>=1"
        - "#changes-requested-reviews-by=0"
        - "label!=do-not-merge"
        - "label!=multiple-reviewers"
        - "label!=mergify-ignore"
        - "label!=M-do-not-merge"
        - "label!=M-multiple-reviewers"
        - "label!=M-mergify-ignore"
        - "base=develop"
    actions:
      queue:
        name: default
        method: merge
        merge_bot_account: OptimismBot
  - name: Add merge train label
    conditions:
      - "queue-position >= 0"
    actions:
      comment:
          message: |
            This PR has been added to the merge queue, and will be merged soon.
      label:
        add:
          - S-on-merge-train
  - name: Remove merge train label
    conditions:
      - "queue-position = -1"
    actions:
      label:
        remove:
          - S-on-merge-train
  - name: Ask to resolve conflict
    conditions:
      - conflict
    actions:
      comment:
        message: Hey @{{author}}! This PR has merge conflicts. Please fix them before continuing review.
      label:
        add:
          - S-conflict
  - name: Remove conflicts label when conflicts gone
    conditions:
      - -conflict
    actions:
      label:
        remove:
          - S-conflict
  - name: Notify author when added to merge queue
    conditions:
      - "check-pending=Queue: Embarked in merge train"
    actions:
      comment:
        message: |
          This PR is next in line to be merged, and will be merged as soon as checks pass.
  - name: Notify author on queue failure
    conditions:
      - 'check-failure=Queue: Embarked in merge train'
    actions:
      comment:
        message: >
          Hey @{{ author }}, this pull request failed to merge and has been
          dequeued from the merge train.  If you believe your PR failed in
          the merge train because of a flaky test, requeue it by commenting
          with `@mergifyio requeue`.

          More details can be found on the `Queue: Embarked in merge train`
          check-run.
  - name: Add A-cannon label
    conditions:
      - 'files~=^cannon/'
    actions:
      label:
        add:
          - A-cannon
  - name: Add A-indexer label and ecopod reviewers
    conditions:
      - 'files~=^indexer/'
      - '#label<5'
    actions:
      label:
        add:
          - A-indexer
      request_reviews:
        users:
          - roninjin10
  - name: Add A-op-batcher label
    conditions:
      - 'files~=^op-batcher/'
    actions:
      label:
        add:
          - A-op-batcher
  - name: Add A-op-bindings label
    conditions:
      - 'files~=^op-bindings/'
    actions:
      label:
        add:
          - A-op-bindings
  - name: Add A-op-bootnode label
    conditions:
      - 'files~=^op-bootnode/'
      - '#label<5'
    actions:
      label:
        add:
          - A-op-bootnode
  - name: Add A-op-chain-ops label
    conditions:
      - 'files~=^op-chain-ops/'
    actions:
      label:
        add:
          - A-op-chain-ops
  - name: Add A-op-challenger label
    conditions:
      - 'files~=^op-challenger/'
    actions:
      label:
        add:
          - A-op-challenger
  - name: Add A-op-e2e label
    conditions:
      - 'files~=^op-e2e/'
      - '#label<5'
    actions:
      label:
        add:
          - A-op-e2e
  - name: Add A-op-heartbeat label
    conditions:
      - 'files~=^op-heartbeat/'
      - '#label<5'
    actions:
      label:
        add:
          - A-op-heartbeat
  - name: Add A-op-node label
    conditions:
      - 'files~=^op-node/'
    actions:
      label:
        add:
          - A-op-node
  - name: Add A-op-preimage label
    conditions:
      - 'files~=^op-preimage/'
      - '#label<5'
    actions:
      label:
        add:
          - A-op-preimage
  - name: Add A-op-program label
    conditions:
      - 'files~=^op-program/'
    actions:
      label:
        add:
          - A-op-program
  - name: Add A-op-proposer label
    conditions:
      - 'files~=^op-proposer/'
    actions:
      label:
        add:
          - A-op-proposer
  - name: Add A-op-service label
    conditions:
      - 'files~=^op-service/'
      - '#label<5'
    actions:
      label:
        add:
          - A-op-service
  - name: Add A-op-wheel label
    conditions:
      - 'files~=^op-wheel/'
      - '#label<5'
    actions:
      label:
        add:
          - A-op-wheel
  - name: Add A-ops-bedrock label
    conditions:
      - 'files~=^ops-bedrock/'
      - '#label<5'
    actions:
      label:
        add:
          - A-ops-bedrock
  - name: Add A-ops label
    conditions:
      - 'files~=^ops/'
      - '#label<5'
    actions:
      label:
        add:
          - A-ops
  - name: Add A-pkg-chain-mon label
    conditions:
      - 'files~=^packages/chain-mon/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-chain-mon
  - name: Add A-pkg-common-ts label and ecopod reviewers
    conditions:
      - 'files~=^packages/common-ts/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-common-ts
      request_reviews:
        users:
          - roninjin10
  - name: Add A-pkg-contracts-bedrock label
    conditions:
      - 'files~=^packages/contracts-bedrock/'
    actions:
      label:
        add:
          - A-pkg-contracts-bedrock
  - name: Add A-pkg-contracts-ts label
    conditions:
      - 'files~=^packages/contracts-ts/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-contracts-ts
  - name: Add A-pkg-core-utils label
    conditions:
      - 'files~=^packages/core-utils/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-core-utils
  - name: Add A-pkg-fee-estimation label
    conditions:
      - 'files~=^packages/fee-estimation/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-fee-estimation
  - name: Add A-pkg-sdk label and ecopod reviewers
    conditions:
      - 'files~=^packages/sdk/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-sdk
      request_reviews:
        users:
          - roninjin10
  - name: Add A-pkg-web3js-plugin label
    conditions:
      - 'files~=^packages/web3js-plugin/'
      - '#label<5'
    actions:
      label:
        add:
          - A-pkg-web3js-plugin
  - name: Add A-proxyd label
    conditions:
      - 'files~=^proxyd/'
      - '#label<5'
    actions:
      label:
        add:
          - A-proxyd
  - name: Add M-docs label
    conditions:
      - 'files~=^(docs|specs)\/'
      - '#label<5'
    actions:
      label:
        add:
          - M-docs
  - name: Add M-deletion label when files are removed
    conditions:
      - 'removed-files~=^/'
    actions:
      label:
        add:
          - M-deletion
  - name: Add M-ci label when ci files are modified
    conditions:
      - 'files~=^\.(github|circleci|husky)\/'
      - '#label<5'
    actions:
      label:
        add:
          - M-ci
