1234567891011121314151617181920212223242526272829303132333435363738 |
- name: Backport
- on:
- workflow_dispatch:
- inputs:
- number:
- description: "The pull request # to backport"
- required: true
- jobs:
- backport:
- runs-on: ubuntu-latest
- steps:
- - uses: actions/checkout@v3
- with:
- # history is needed to run git cherry-pick below
- fetch-depth: 0
- - name: Set git user
- run: .github/scripts/set-git-user.sh
- - name: Create pull request
- env:
- NUMBER: ${{ github.event.inputs.number }}
- # not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
- GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
- run: |
- commit=$(gh pr view $NUMBER --json mergeCommit --jq .mergeCommit.oid)
- title=$(gh pr view $NUMBER --json title --jq .title)
- url=$(gh pr view $NUMBER --json url --jq .url)
- branch="backport-${NUMBER}-to-${GITHUB_REF_NAME//\//-}"
- git cherry-pick $commit
- git push origin HEAD:$branch
- gh pr create --title "[$GITHUB_REF_NAME] $title" \
- --body "Clean cherry-pick of #$NUMBER to the \`$GITHUB_REF_NAME\` branch." \
- --head $branch \
- --base $GITHUB_REF_NAME
|