git_sync.yaml 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. name: Sync to enterprise
  2. on:
  3. push:
  4. branches:
  5. - main-v*
  6. jobs:
  7. sync_to_enterprise:
  8. runs-on: ubuntu-20.04
  9. if: github.repository == 'emqx/emqx'
  10. steps:
  11. - name: git-sync
  12. uses: Rory-Z/git-sync@v3.0.1
  13. with:
  14. source_repo: ${{ github.repository }}
  15. source_branch: ${{ github.ref }}
  16. destination_repo: "${{ github.repository_owner }}/emqx-enterprise"
  17. destination_branch: ${{ github.ref }}
  18. destination_ssh_private_key: "${{ secrets.CI_SSH_PRIVATE_KEY }}"
  19. - name: create pull request
  20. id: create_pull_request
  21. run: |
  22. set -euo pipefail
  23. EE_REF="${GITHUB_REF}-enterprise"
  24. R=$(curl --silent --show-error \
  25. -H "Accept: application/vnd.github.v3+json" \
  26. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  27. -X POST \
  28. -d "{\"title\": \"Sync code from opensource $GITHUB_REF to entperprise $EE_REF\", \"head\": \"$GITHUB_REF\", \"base\":\"$EE_REF\"}" \
  29. https://api.github.com/repos/${{ github.repository_owner }}/emqx-enterprise/pulls)
  30. echo $R | jq
  31. echo "::set-output name=url::$(echo $R | jq '.url')"
  32. - name: request reviewers for a pull request
  33. if: steps.create_pull_request.outputs.url != 'null'
  34. run: |
  35. set -euo pipefail
  36. curl --silent --show-error \
  37. -H "Accept: application/vnd.github.v3+json" \
  38. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  39. -X POST \
  40. -d '{"team_reviewers":["emqx-devs"]}' \
  41. ${{ steps.create_pull_request.outputs.url }}/requested_reviewers