1+ name : Refresh Connector Schema
2+ on :
3+ schedule :
4+ - cron : ' 0 13 1 * *'
5+ jobs :
6+ generate :
7+ name : generate schema
8+ runs-on : ubuntu-latest
9+ steps :
10+ - uses : actions/checkout@v4
11+ - uses : actions/setup-go@v5
12+ with :
13+ go-version-file : ' go.mod'
14+
15+ - name : Install DaVinci CLI
16+ run : go install github.com/patrickcping/davinci-pingcli
17+ continue-on-error : false
18+
19+ - name : Generate Connector Schema
20+ run : |
21+ davinci-pingcli connectors schema --json | jq '[.[] | .accountConfigView.items as $items | {"name": .name, "connectorId": .connectorId, "connectorCategories": .connectorCategories, "properties": (.properties // {} | with_entries(select(.key as $k | ($items // [] | map(.propertyName)) | index($k))))}]' > internal/generate/connector_schema/connector-schema.json
22+ continue-on-error : false
23+
24+ - name : Check for changes
25+ id : check_changes
26+ run : |
27+ git add -N .
28+ if git diff --compact-summary --exit-code; then
29+ echo "No changes detected"
30+ else
31+ echo "Changes detected"
32+ echo "CONTENT_CHANGED=true" >> $GITHUB_OUTPUT
33+ fi
34+ continue-on-error : false
35+
36+ - name : Create new branch
37+ id : create_branch
38+ if : steps.check_changes.outputs.CONTENT_CHANGED == 'true'
39+ run : |
40+ branch_name="update-connector-schema-$(date +'%Y%m%d%H%M%S')"
41+ echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
42+ git checkout -b $branch_name
43+
44+ - name : Commit changes
45+ id : commit_changes
46+ if : steps.check_changes.outputs.CONTENT_CHANGED == 'true'
47+ run : |
48+ git config --local user.name "github-actions[bot]"
49+ git config --local user.email "action@github.com"
50+ git config --global push.autoSetupRemote true
51+ git add .
52+ git commit -m "Update connector schema"
53+ git push
54+
55+ - name : Create PR
56+ id : create_pr
57+ if : steps.check_changes.outputs.CONTENT_CHANGED == 'true'
58+ uses : actions/github-script@v7
59+ env :
60+ BRANCH_NAME : ${{ env.BRANCH_NAME }}
61+ with :
62+ script : |
63+ const { BRANCH_NAME } = process.env
64+ const { repo, owner } = context.repo;
65+ const pr = await github.rest.pulls.create({
66+ owner,
67+ repo,
68+ title: 'Update Connector Schema',
69+ body: 'Connector Schema has changed. Please review.',
70+ head: BRANCH_NAME,
71+ base: 'main'
72+ });
0 commit comments