pull_request_rules:
  - name: put PR in draft if conflicts
    conditions:
      - label = conflicts
      - author = mergify[bot]
      - head ~= ^mergify/
    actions:
      edit:
         draft: true
  - name: Delete mergify backport branch
    conditions:
      - base~=branch-
      - or:
        - merged
        - closed
    actions:
      delete_head_branch:
  - name: Automate backport pull request 6.2
    conditions:
      - or:
        - closed
        - merged
      - or:
          - base=master
          - base=next
      - label=backport/6.2 # The PR must have this label to trigger the backport
      - label=promoted-to-master
    actions:
      copy:
        title: "[Backport 6.2] {{ title }}"
        body: |
          {{ body }}

          {% for c in commits %}
          (cherry picked from commit {{ c.sha }})
          {% endfor %}

          Refs #{{number}}
        branches:
          - branch-6.2
        assignees:
          - "{{ author }}"
  - name: Automate backport pull request 6.1
    conditions:
      - or:
        - closed
        - merged
      - or:
          - base=master
          - base=next
      - label=backport/6.1 # The PR must have this label to trigger the backport
      - label=promoted-to-master
    actions:
      copy:
        title: "[Backport 6.1] {{ title }}"
        body: |
          {{ body }}

          {% for c in commits %}
          (cherry picked from commit {{ c.sha }})
          {% endfor %}

           Refs #{{number}}
        branches:
          - branch-6.1
        assignees:
          - "{{ author }}"
  - name: Automate backport pull request 6.0
    conditions:
      - or:
        - closed
        - merged
      - or:
          - base=master
          - base=next
      - label=backport/6.0 # The PR must have this label to trigger the backport
      - label=promoted-to-master
    actions:
      copy:
        title: "[Backport 6.0] {{ title }}"
        body: |
          {{ body }}

          {% for c in commits %}
          (cherry picked from commit {{ c.sha }})
          {% endfor %}

           Refs #{{number}}
        branches:
          - branch-6.0
        assignees:
          - "{{ author }}"
