merge-change-log-to-main.yml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. name: Merge change log to main
  2. on:
  3. workflow_dispatch:
  4. jobs:
  5. create-pull-request:
  6. runs-on: ubuntu-latest
  7. steps:
  8. - uses: actions/checkout@v3
  9. with:
  10. # this workflow is run against the release branch (see usage of GITHUB_REF_NAME below)
  11. # but it is creating a pull request against main
  12. ref: main
  13. # history is needed to run format-patch below
  14. fetch-depth: 0
  15. - name: Set git user
  16. run: .github/scripts/set-git-user.sh
  17. # this will fail if there have been conflicting change log updates introduced in main
  18. - name: Create pull request against main
  19. env:
  20. # not using the default GITHUB_TOKEN because pull requests generated by it do not run any workflows
  21. GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
  22. run: |
  23. message="Merge change log updates from $GITHUB_REF_NAME"
  24. body="Merge change log updates from \`$GITHUB_REF_NAME\`."
  25. branch="merge-change-log-updates-from-${GITHUB_REF_NAME//\//-}"
  26. git format-patch --stdout HEAD..origin/$GITHUB_REF_NAME CHANGELOG.md | git apply --3way
  27. git commit -a -m "$message"
  28. git push origin HEAD:$branch
  29. gh pr create --title "$message" \
  30. --body "$body" \
  31. --head $branch \
  32. --base main