git_sync.yaml 1.8 KB

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