git_sync.yaml 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. EE_REF="${GITHUB_REF}-enterprise"
  26. R=$(curl --silent --show-error \
  27. -H "Accept: application/vnd.github.v3+json" \
  28. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  29. -X POST \
  30. -d "{\"title\": \"Sync code from opensource $GITHUB_REF to entperprise $EE_REF\", \"head\": \"$GITHUB_REF\", \"base\":\"$EE_REF\"}" \
  31. https://api.github.com/repos/${{ github.repository_owner }}/emqx-enterprise/pulls)
  32. echo $R | jq
  33. echo "::set-output name=url::$(echo $R | jq '.url')"
  34. - name: request reviewers for a pull request
  35. if: steps.create_pull_request.outputs.url != 'null'
  36. run: |
  37. set -euo pipefail
  38. curl --silent --show-error \
  39. -H "Accept: application/vnd.github.v3+json" \
  40. -H "Authorization: token ${{ secrets.CI_GIT_TOKEN }}" \
  41. -X POST \
  42. -d '{"team_reviewers":["emqx-devs"]}' \
  43. ${{ steps.create_pull_request.outputs.url }}/requested_reviewers