robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

robinmerge: 1dc9728daa1d8a2702

master
1.6 KiB47 linesraw
1name: backport
2on:
3  pull_request_target:
4    types: [closed, labeled]
5
6permissions: {}
7
8jobs:
9  backport:
10    permissions:
11      contents: write
12      pull-requests: write
13    name: Backport Pull Request
14    if: github.event.pull_request.merged
15    runs-on: ubuntu-latest
16    steps:
17      - uses: actions/checkout@v7.0.1
18        with:
19          persist-credentials: true
20          # Check out the merged-into base branch by name. Without an explicit
21          # ref, checkout resolves to the base tip SHA, which for a _merged_ PR
22          # equals pull_request.merge_commit_sha and trips the
23          # actions/checkout@v7.0.1 `allow-unsafe-pr-checkout` guard (false
24          # positive: this is trusted base code, not fork PR code).
25          ref: ${{ github.event.pull_request.base.ref }}
26
27      - uses: actions/create-github-app-token@v3.2.0
28        id: app-token
29        with:
30          app-id: ${{ vars.BACKPORT_APP }}
31          private-key: ${{ secrets.BACKPORT_KEY }}
32
33      - name: Create backport PR
34        id: backport
35        uses: korthout/backport-action@6b65649031ac6d18ffdfd0c0820e9436f3fde22b # v4.6.1
36        with:
37          pull_title: "backport: ${pull_title}"
38          label_pattern: "^ci:backport ([^ ]+)$"
39          github_token: ${{ steps.app-token.outputs.token }}
40
41      - name: Enable automerge
42        if: ${{ steps.backport.outputs.was_successful == 'true' }}
43        env:
44          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45          CREATED_PULL_NUMBERS: ${{ steps.backport.outputs.created_pull_numbers }}
46        run: |
47          gh pr merge --rebase --auto "${CREATED_PULL_NUMBERS}"