---
name: Backport Assistant Runner

on:
  pull_request_target:
    types:
      - closed
  pull_request:
    types:
      - labeled

permissions:
  contents: write # to push to a new branch
  pull-requests: write # to create a new PR

jobs:
  backport:
    if: github.event.pull_request
    runs-on: ubuntu-latest
    container: hashicorpdev/backport-assistant:0.5.8@sha256:b18bc289f405beb58aa22a1b4b3bdac42394fad602541ed94a0f9c5e3f66f954
    steps:
      - name: Run Backport Assistant
        run: |
          backport-assistant backport
        env:
          BACKPORT_LABEL_REGEXP: "(?P<target>\\d+\\.\\d+)-backport"
          BACKPORT_TARGET_TEMPLATE: "v{{.target}}"
          BACKPORT_CREATE_DRAFT_ALWAYS: true
          GITHUB_TOKEN: ${{ github.token }}
