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