aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/backport.yml
blob: 71c0e2a9842b41d74f227f71691cc095dc84a933 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: backport
on:
  pull_request_target:
    types: [closed, labeled]
jobs:
  backport:
    permissions:
      contents: write
      pull-requests: write
    name: Backport Pull Request
    if: github.event.pull_request.merged
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - uses: actions/create-github-app-token@v2
        id: app-token
        with:
          app-id: ${{ vars.BACKPORT_APP }}
          private-key: ${{ secrets.BACKPORT_KEY }}

      - name: Create backport PR
        id: backport
        uses: korthout/backport-action@v3
        with:
          pull_title: "${pull_title}"
          label_pattern: "^ci:backport ([^ ]+)$"
          github_token: ${{ steps.app-token.outputs.token }}

      - name: Create failed backport label
        if: ${{ steps.backport.outputs.was_successful == 'false' }}
        uses: actions/github-script@v7
        with:
          script: |
            github.rest.issues.addLabels({
              issue_number: context.issue.number,
              owner: context.repo.owner,
              repo: context.repo.repo,
              labels: ['needs:backport']
            })

      - name: Enable automerge
        if: ${{ steps.backport.outputs.was_successful == 'true' }}
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        run: gh pr merge --rebase --auto ${{ steps.backport.outputs.created_pull_numbers }}