Skip to content

Commit

Permalink
chore: add backport github action (#9835)
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinaecalderon authored Aug 22, 2024
1 parent a37e6e7 commit fb95df8
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/backport.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: backport
on:
pull_request_target:
types:
- closed
- labeled

jobs:
backport_and_merge:
runs-on: ubuntu-latest
# Only react to merged PRs for security reasons.
# See https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#pull_request_target.
permissions:
contents: write
pull-requests: write
if: |
github.event.pull_request.merged && (
github.event.action == 'closed' || (
github.event.action == 'labeled' && contains(github.event.label.name, 'backport')
)
)
steps:
- name: backport PR
uses: tibdex/backport@v2
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
title_template: "[AUTO-BACKPORT <%= number %>] <%= title %>"

- name: wait-for-checks
uses: poseidon/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: merge backported PR
id: merge_backport_pr
if: success()
run: |
PR_NUMBER=$(gh pr list --repo ${{ github.repository }} --search "[AUTO-BACKPORT ${{ github.event.pull_request.number }}]" --json number --jq '.[0].number')
if [ -n "$PR_NUMBER" ]; then
gh pr merge $PR_NUMBER --merge --repo ${{ github.repository }} --admin -t "Auto-merged backport PR."
else
echo "No backport PR found to merge."
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 comments on commit fb95df8

Please sign in to comment.