backport-pull-request.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. name: Backport a pull request
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. pr:
  6. description: "The pull request # to backport"
  7. required: true
  8. jobs:
  9. backport:
  10. runs-on: ubuntu-latest
  11. steps:
  12. - uses: actions/checkout@v3
  13. with:
  14. # need full tree in order to do cherry-pick
  15. fetch-depth: 0
  16. - name: Setup git name
  17. run: |
  18. git config user.name opentelemetry-java-bot
  19. git config user.email 97938252+opentelemetry-java-bot@users.noreply.github.com
  20. - name: Create pull request
  21. env:
  22. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  23. PR: ${{ github.event.inputs.pr }}
  24. run: |
  25. commit=$(gh pr view $PR --json mergeCommit --jq .mergeCommit.oid)
  26. title=$(gh pr view $PR --json title --jq .title)
  27. url=$(gh pr view $PR --json url --jq .url)
  28. git cherry-pick $commit
  29. git push origin HEAD:backport-$PR-to-$GITHUB_REF_NAME
  30. gh pr create --title "[$GITHUB_REF_NAME] $title" \
  31. --body "Clean cherry-pick of #$PR to the $GITHUB_REF_NAME branch." \
  32. --head backport-$PR-to-$GITHUB_REF_NAME \
  33. --base $GITHUB_REF_NAME