-
Notifications
You must be signed in to change notification settings - Fork 1
136 lines (120 loc) · 5.09 KB
/
refresh-connector-schema.yml
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: Refresh Connector Schema
on:
workflow_dispatch:
schedule:
- cron: '0 13 1 * *'
jobs:
generate:
name: generate schema
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'
- name: Install DaVinci CLI
run: cd tools && go install github.com/patrickcping/davinci-pingcli
continue-on-error: false
- name: Generate Connector Schema
run: |
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))))}] | sort_by(.connectorId)' > dvgenerate/internal/connector_schema/connector-schema.json
continue-on-error: false
env:
PINGCLI_DAVINCI_USERNAME: ${{ secrets.PINGCLI_DAVINCI_USERNAME }}
PINGCLI_DAVINCI_PASSWORD: ${{ secrets.PINGCLI_DAVINCI_PASSWORD }}
PINGCLI_DAVINCI_ADMINENVIRONMENTID: ${{ secrets.PINGCLI_DAVINCI_ADMIN_ENVIRONMENT_ID }}
PINGCLI_DAVINCI_ENVIRONMENTID: ${{ secrets.PINGCLI_DAVINCI_ENVIRONMENT_ID }}
PINGCLI_DAVINCI_REGION: ${{ secrets.PINGCLI_DAVINCI_REGION }}
- name: Check for changes
id: check_changes
run: |
git add -N .
if git diff --compact-summary --exit-code; then
echo "No changes detected"
else
echo "Changes detected"
echo "CONTENT_CHANGED=true" >> $GITHUB_OUTPUT
fi
continue-on-error: false
- name: Create new branch
id: create_branch
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
branch_name="update-connector-schema-$(date +'%Y%m%d%H%M%S')"
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
git checkout -b $branch_name
- name: Commit changes
id: commit_changes
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "action@github.com"
git config --global push.autoSetupRemote true
git add .
git commit -m "Update connector schema"
git push
- name: Get dependencies
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
go mod download
- name: Check dependencies
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
make depscheck
- name: Vet
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
make vet
- name: Build
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
make build
- uses: hashicorp/setup-terraform@v3
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
- run: cd tools && go install github.com/hashicorp/terraform-plugin-docs/cmd/tfplugindocs
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
- run: cd tools && go install github.com/katbyte/terrafmt
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
- run: make generate
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
- name: Commit changes
id: commit_generated_doc_changes
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
git add .
git commit -m "Update generated documentation/code"
git push
- name: Create PR
id: create_pr
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
uses: actions/github-script@v7
env:
BRANCH_NAME: ${{ env.BRANCH_NAME }}
with:
script: |
const { BRANCH_NAME } = process.env
const { repo, owner } = context.repo;
const date = new Date();
const formattedDate = `${String(date.getDate()).padStart(2, '0')}-${date.toLocaleString('default', { month: 'short' })}-${date.getFullYear()}`;
const pr = await github.rest.pulls.create({
owner,
repo,
title: `Update Connector Schema (${formattedDate})`,
body: 'Connector Schema has changed. Please review.',
head: BRANCH_NAME,
base: 'main',
labels: ['Documentation']
});
core.setOutput('PR_NUMBER', pr.data.number);
- name: Add changelog entry
id: create_changelog_entry
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
echo -e "\`\`\`release-note:note\nUpdate Connector Reference Guide ($(date +'%d %B %Y')).\n\`\`\`" > .changelog/${{ steps.create_pr.outputs.PR_NUMBER }}.txt
- name: Commit changes
id: commit_changelog
if: steps.check_changes.outputs.CONTENT_CHANGED == 'true'
run: |
git add .
git commit -m "Update changelog"
git push