git_sync.yaml 1.8 KB

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