-
Notifications
You must be signed in to change notification settings - Fork 19
174 lines (152 loc) · 5.61 KB
/
sdk-reference-sync.yml
File metadata and controls
174 lines (152 loc) · 5.61 KB
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
name: Sync SDK Reference Documentation
on:
workflow_dispatch:
inputs:
sdk:
description: "SDK to generate (see sdks.config.ts for available SDKs, or use 'all')"
required: true
default: "all"
type: string
version:
description: "Version to generate (all, latest, or specific like v2.9.0)"
required: true
default: "latest"
type: string
limit:
description: "Limit number of versions to generate (default: 5)"
required: false
default: 5
type: number
force:
description: "Force regeneration of existing versions"
required: false
default: false
type: boolean
repository_dispatch:
types: [sdk-release]
# prevent concurrent runs that could conflict
concurrency:
group: sdk-reference-${{ github.ref }}
cancel-in-progress: false
jobs:
generate:
runs-on: ubuntu-latest
timeout-minutes: 30
permissions:
contents: write
steps:
- name: Checkout docs repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Cache pnpm dependencies
uses: actions/cache@v4
with:
path: |
~/.pnpm-store
sdk-reference-generator/node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('sdk-reference-generator/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
- name: Install generator dependencies
working-directory: sdk-reference-generator
run: pnpm install --frozen-lockfile
- name: Install Python dependencies
run: pip install -r requirements.txt
- name: Determine SDK and Version
id: params
env:
EVENT_NAME: ${{ github.event_name }}
INPUT_SDK: ${{ github.event.inputs.sdk }}
INPUT_VERSION: ${{ github.event.inputs.version }}
INPUT_LIMIT: ${{ github.event.inputs.limit }}
INPUT_FORCE: ${{ github.event.inputs.force }}
PAYLOAD_SDK: ${{ github.event.client_payload.sdk }}
PAYLOAD_VERSION: ${{ github.event.client_payload.version }}
PAYLOAD_LIMIT: ${{ github.event.client_payload.limit }}
run: |
if [[ "$EVENT_NAME" == "workflow_dispatch" ]]; then
SDK="$INPUT_SDK"
VERSION="$INPUT_VERSION"
LIMIT="$INPUT_LIMIT"
FORCE="$INPUT_FORCE"
elif [[ "$EVENT_NAME" == "repository_dispatch" ]]; then
SDK="$PAYLOAD_SDK"
VERSION="${PAYLOAD_VERSION:-latest}"
LIMIT="${PAYLOAD_LIMIT:-5}"
FORCE="false"
fi
echo "sdk=${SDK:-all}" >> $GITHUB_OUTPUT
echo "version=${VERSION:-latest}" >> $GITHUB_OUTPUT
echo "limit=${LIMIT:-5}" >> $GITHUB_OUTPUT
echo "force=${FORCE:-false}" >> $GITHUB_OUTPUT
- name: Generate SDK Reference
working-directory: sdk-reference-generator
env:
SDK_NAME: ${{ steps.params.outputs.sdk }}
SDK_VERSION: ${{ steps.params.outputs.version }}
LIMIT: ${{ steps.params.outputs.limit }}
FORCE: ${{ steps.params.outputs.force }}
FORCE_COLOR: "2"
run: |
ARGS="--sdk $SDK_NAME --version $SDK_VERSION"
if [[ -n "$LIMIT" && "$LIMIT" != "0" ]]; then
ARGS="$ARGS --limit $LIMIT"
fi
if [[ "$FORCE" == "true" ]]; then
ARGS="$ARGS --force"
fi
pnpm run generate $ARGS
- name: Commit and push changes
id: commit
env:
SDK_NAME: ${{ steps.params.outputs.sdk }}
SDK_VERSION: ${{ steps.params.outputs.version }}
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add docs/sdk-reference/
git add docs.json
if git diff --staged --quiet; then
echo "No changes to commit"
echo "changes=false" >> $GITHUB_OUTPUT
else
git commit -m "docs: update SDK reference for $SDK_NAME $SDK_VERSION"
git push
echo "changes=true" >> $GITHUB_OUTPUT
fi
- name: Summary
env:
SDK_NAME: ${{ steps.params.outputs.sdk }}
SDK_VERSION: ${{ steps.params.outputs.version }}
LIMIT: ${{ steps.params.outputs.limit }}
CHANGES: ${{ steps.commit.outputs.changes }}
run: |
echo "## SDK Reference Generation Complete" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Parameter | Value |" >> $GITHUB_STEP_SUMMARY
echo "|-----------|-------|" >> $GITHUB_STEP_SUMMARY
echo "| SDK | $SDK_NAME |" >> $GITHUB_STEP_SUMMARY
echo "| Version | $SDK_VERSION |" >> $GITHUB_STEP_SUMMARY
echo "| Limit | ${LIMIT:-No limit} |" >> $GITHUB_STEP_SUMMARY
echo "| Changes committed | $CHANGES |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [[ "$CHANGES" == "true" ]]; then
echo "### Generated Files" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "Total MDX files: $(find docs/sdk-reference -type f -name '*.mdx' | wc -l)" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
fi