Skip to content

Commit 04d83f2

Browse files
authored
ci: GH-17 Automating regular spec updates (#21)
* ci: GH-17 Adding update-sdk workflow * ci: GH-17 Using mkdocs-awesome-nav to automatically include files in their respective nav sections * ci: GH-17 Adding changeset when running update-sdk * ci: GH-17 Adding codeowners file and automerge setup for the PR created by update-sdk * ci: GH-17 Adding workflow_dispatch to update-sdk triggers * ci: GH-17 Removing check for SDK needing to be up to date on every PR
1 parent cc6947e commit 04d83f2

10 files changed

Lines changed: 95 additions & 169 deletions

File tree

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// Features to add to the dev container. More info: https://containers.dev/features.
99
"features": {
1010
"ghcr.io/devcontainers-extra/features/mkdocs:2": {
11-
"plugins": "mkdocs-material mkdocs-exclude"
11+
"plugins": "mkdocs-material mkdocs-exclude mkdocs-awesome-nav"
1212
},
1313
"ghcr.io/devcontainers/features/docker-in-docker:2": {
1414
"moby": false

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* @Tohaker

.github/workflows/ci.yml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818

1919
- uses: actions/setup-python@v6
2020
with:
21-
python-version: '3.13'
21+
python-version: "3.13"
2222

2323
- name: Install openapi-spec-validator
2424
run: pip install openapi-spec-validator
@@ -38,11 +38,5 @@ jobs:
3838
with:
3939
go-version-file: go.mod
4040

41-
- name: Generate SDK
42-
run: make all
43-
44-
- name: Check for uncommitted changes
45-
run: |
46-
if [[ -n $(git status --porcelain) ]]; then
47-
echo "::error::SDK changes detected. Make sure you have pushed all generated changes" && exit 1
48-
fi
41+
- name: Check SDK builds
42+
run: make tidy verify

.github/workflows/deploy-docs.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ on:
77
paths:
88
- mkdocs.yml
99
- omada/README.md
10-
- 'omada/docs/**'
10+
- omada/.nav.yml
11+
- "omada/docs/**"
1112

1213
permissions:
1314
contents: write
1415

1516
jobs:
1617
deploy:
17-
runs-on: ubuntu-slim
18+
runs-on: ubuntu-latest
1819
steps:
1920
- uses: actions/checkout@v6
2021

@@ -27,15 +28,15 @@ jobs:
2728
with:
2829
python-version: 3.x
2930

30-
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
31+
- run: echo "cache_id=$(date --utc '+%V')" >> $GITHUB_ENV
3132

3233
- uses: actions/cache@v5
3334
with:
3435
key: mkdocs-material-${{ env.cache_id }}
35-
path: ~/.cache
36+
path: ~/.cache
3637
restore-keys: |
3738
mkdocs-material-
3839
39-
- run: pip install mkdocs-material mkdocs-exclude
40-
41-
- run: mkdocs gh-deploy --force
40+
- run: pip install mkdocs-material mkdocs-exclude mkdocs-awesome-nav
41+
42+
- run: mkdocs gh-deploy --force

.github/workflows/update-sdk.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
on:
2+
workflow_dispatch:
3+
schedule:
4+
- cron: "0 1 * * *"
5+
6+
permissions:
7+
contents: write
8+
pull-requests: write
9+
10+
env:
11+
BRANCH: chore/update-sdk
12+
13+
jobs:
14+
update:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Configure Git Credentials
20+
run: |
21+
git config user.name github-actions[bot]
22+
git config user.email github-actions[bot]@users.noreply.github.com
23+
24+
- uses: actions/setup-go@v6
25+
with:
26+
go-version-file: go.mod
27+
28+
- name: Generate SDK
29+
run: make all
30+
31+
- name: Check for changes
32+
id: check_changes
33+
run: |
34+
if [[ -n $(git status --porcelain) ]]; then
35+
echo "has_changes=true" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- name: Create changeset
39+
if: ${{ steps.check_changes.outputs.has_changes == 'true' }}
40+
run: |
41+
mkdir -p .changeset/
42+
cat <<EOF > .changeset/update_sdk_changeset.md
43+
---
44+
omada-go-sdk: minor
45+
---
46+
47+
chore: Updating generated SDK to match latest OpenAPI spec
48+
EOF
49+
50+
- name: Commit and push changes
51+
if: ${{ steps.check_changes.outputs.has_changes == 'true' }}
52+
run: |
53+
git checkout -B "${{ env.BRANCH }}"
54+
git add --all
55+
git commit -m "chore: update generated SDK"
56+
git push --force origin "${{ env.BRANCH }}"
57+
58+
- name: Create PR
59+
if: ${{ steps.check_changes.outputs.has_changes == 'true' }}
60+
run: |
61+
existing=$(gh pr list --head ${{ env.BRANCH }} --json number --jq '.[0].number')
62+
if [[ -z "$existing" ]]; then
63+
gh pr create \
64+
--title "chore: update generated SDK" \
65+
--body "Automated SDK regeneration from latest OpenAPI spec." \
66+
--head ${{ env.BRANCH }}
67+
gh pr merge --auto --squash
68+
fi

.vscode/settings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
"yaml.schemas": {
33
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yml"
44
},
5-
"yaml.customTags": [
5+
"yaml.customTags": [
66
"!ENV scalar",
77
"!ENV sequence",
88
"!relative scalar",
99
"tag:yaml.org,2002:python/name:material.extensions.emoji.to_svg",
1010
"tag:yaml.org,2002:python/name:material.extensions.emoji.twemoji",
1111
"tag:yaml.org,2002:python/name:pymdownx.superfences.fence_code_format",
1212
"tag:yaml.org,2002:python/object/apply:pymdownx.slugs.slugify mapping"
13-
]
13+
],
14+
"makefile.configureOnOpen": false
1415
}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Otherwise, if you haven't done so already, follow their [getting started](https:
143143

144144
You must also install the following extra plugins;
145145
- `mkdocs-exclude`
146+
- `mkdocs-awesome-nav`
146147

147148
To preview the docs locally, just run
148149

mkdocs.yml

Lines changed: 1 addition & 150 deletions
Original file line numberDiff line numberDiff line change
@@ -25,158 +25,9 @@ theme:
2525
icon: material/brightness-4
2626
name: Switch to system preference
2727
docs_dir: omada
28-
nav:
29-
- Home: README.md
30-
- SDK Reference:
31-
- Abnormal Detect: docs/AbnormalDetectAPI.md
32-
- Access Control: docs/AccessControlAPI.md
33-
- Access Control Template: docs/AccessControlTemplateAPI.md
34-
- ACL: docs/ACLAPI.md
35-
- ACL Template: docs/ACLTemplateAPI.md
36-
- AP: docs/ApAPI.md
37-
- Application Control: docs/ApplicationControlAPI.md
38-
- ARP Detection: docs/ArpDetectionAPI.md
39-
- Attack Defense: docs/AttackDefenseAPI.md
40-
- Attack Defense Template: docs/AttackDefenseTemplateAPI.md
41-
- Audit Log: docs/AuditLogAPI.md
42-
- Audit Log Template: docs/AuditLogTemplateAPI.md
43-
- Authentication: docs/AuthenticationAPI.md
44-
- Authentication Template: docs/AuthenticationTemplateAPI.md
45-
- Authorize: docs/AuthorizeAPI.md
46-
- Authorized Client: docs/AuthorizedClientAPI.md
47-
- Backup and Restore: docs/BackupAndRestoreAPI.md
48-
- Bandwidth Control: docs/BandwidthControlAPI.md
49-
- Bandwidth Control Template: docs/BandwidthControlTemplateAPI.md
50-
- Batch OpenAPI: docs/BatchOpenAPIAPI.md
51-
- Bluetooth: docs/BluetoothAPI.md
52-
- Bluetooth Template: docs/BluetoothTemplateAPI.md
53-
- Cert Profiles: docs/CertProfilesAPI.md
54-
- Cert Profiles Template: docs/CertProfilesTemplateAPI.md
55-
- CLI: docs/CLIAPI.md
56-
- CLI Template: docs/CLITemplateAPI.md
57-
- Client: docs/ClientAPI.md
58-
- Client Insight: docs/ClientInsightAPI.md
59-
- Cloud User: docs/CloudUserAPI.md
60-
- Cluster: docs/ClusterAPI.md
61-
- Controller Settings: docs/ControllerSettingsAPI.md
62-
- Customer: docs/CustomerAPI.md
63-
- Dashboard: docs/DashboardAPI.md
64-
- Data Export: docs/DataExportAPI.md
65-
- Device: docs/DeviceAPI.md
66-
- Device Management Setting: docs/DeviceManagementSettingAPI.md
67-
- DHCP Snooping: docs/DhcpSnoopingAPI.md
68-
- Disable NAT: docs/DisableNatAPI.md
69-
- EoGRE Tunnel: docs/EoGRETunnelAPI.md
70-
- Firewall: docs/FirewallAPI.md
71-
- Firewall Template: docs/FirewallTemplateAPI.md
72-
- Firmware: docs/FirmwareAPI.md
73-
- Form Auth Data: docs/FormAuthDataAPI.md
74-
- Gateway: docs/GatewayAPI.md
75-
- Gateway QoS: docs/GatewayQoSAPI.md
76-
- Gateway QoS Template: docs/GatewayQOSTemplateAPI.md
77-
- Gateway Template: docs/GatewayTemplateAPI.md
78-
- Global Dashboard Overview: docs/GlobalDashboardOverviewAPI.md
79-
- Global Security: docs/GlobalSecurityAPI.md
80-
- Health: docs/HealthAPI.md
81-
- History Data Retention: docs/HistoryDataRetentionAPI.md
82-
- Hotspot Operators: docs/HotspotOperatorsAPI.md
83-
- IDSIPS: docs/IDSIPSAPI.md
84-
- IDSIPS Template: docs/IDSIPSTemplateAPI.md
85-
- Insight: docs/InsightAPI.md
86-
- IntelliRecover Client: docs/IntelliRecoverClientAPI.md
87-
- IntelliRecover Device: docs/IntelliRecoverDeviceAPI.md
88-
- IP-MAC Binding: docs/IPMACBindingAPI.md
89-
- IP-MAC Binding Template: docs/IPMACBindingTemplateAPI.md
90-
- LAN Multicast: docs/LanMulticastAPI.md
91-
- LAN Multicast Template: docs/LanMulticastTemplateAPI.md
92-
- License: docs/LicenseAPI.md
93-
- Local User: docs/LocalUserAPI.md
94-
- Log: docs/LogAPI.md
95-
- Log Template: docs/LogTemplateAPI.md
96-
- MAC Filtering: docs/MACFilteringAPI.md
97-
- MAC Filtering Template: docs/MACFilteringTemplateAPI.md
98-
- MLAG: docs/MlagAPI.md
99-
- MSP Batch OpenAPI: docs/MSPBatchOpenAPIAPI.md
100-
- MSP Device: docs/MSPDeviceAPI.md
101-
- MSP History Data Retention: docs/MSPHistoryDataRetentionAPI.md
102-
- MSP License: docs/MspLicenseAPI.md
103-
- MSP Log: docs/MspLogAPI.md
104-
- MSP Setting: docs/MspSettingAPI.md
105-
- MSP Site: docs/MSPSiteAPI.md
106-
- MSP SSO: docs/MSPSSOAPI.md
107-
- MSP User and Role: docs/MSPUserAndRoleAPI.md
108-
- MSP Webhook Setting: docs/MspWebhookSettingAPI.md
109-
- NAT: docs/NATAPI.md
110-
- NAT Template: docs/NATTemplateAPI.md
111-
- Network Analyze: docs/NetworkAnalyzeAPI.md
112-
- Network Report: docs/NetworkReportAPI.md
113-
- OLT: docs/OLTAPI.md
114-
- OLT DBA: docs/OLTDBAAPI.md
115-
- OLT GEM Mapping: docs/OLTGemMappingAPI.md
116-
- OLT GEM Port: docs/OLTGemPortAPI.md
117-
- OLT Line Profile: docs/OLTLineProfileAPI.md
118-
- OLT ONT Port: docs/OLTONTPortAPI.md
119-
- OLT ONU Management: docs/OLTONUManagementAPI.md
120-
- OLT ONU Register: docs/OLTONURegisterAPI.md
121-
- OLT PON Port: docs/OLTPonPortAPI.md
122-
- OLT Service Port: docs/OLTServicePortAPI.md
123-
- OLT Service Port Profile: docs/OLTServicePortProfileAPI.md
124-
- OLT Service Profile: docs/OLTServiceProfileAPI.md
125-
- OLT TCont: docs/OLTTContAPI.md
126-
- OLT Traffic Profile: docs/OLTTrafficProfileAPI.md
127-
- OSPF: docs/OSPFAPI.md
128-
- OUI-Based VLAN: docs/OUIBasedVLANAPI.md
129-
- OUI-Based VLAN Template: docs/OUIBasedVLANTemplateAPI.md
130-
- Profiles: docs/ProfilesAPI.md
131-
- Profiles Template: docs/ProfilesTemplateAPI.md
132-
- Quick Action: docs/QuickActionAPI.md
133-
- Remote Access: docs/RemoteAccessAPI.md
134-
- Report V2: docs/ReportV2API.md
135-
- Routing: docs/RoutingAPI.md
136-
- Routing Template: docs/RoutingTemplateAPI.md
137-
- RRM: docs/RrmAPI.md
138-
- Schedule: docs/ScheduleAPI.md
139-
- Schedule Template: docs/ScheduleTemplateAPI.md
140-
- SD-WAN: docs/SDWANAPI.md
141-
- Service: docs/ServiceAPI.md
142-
- Service Template: docs/ServiceTemplateAPI.md
143-
- Session Limit: docs/SessionLimitAPI.md
144-
- Session Limit Template: docs/SessionLimitTemplateAPI.md
145-
- SIM: docs/SIMAPI.md
146-
- SIM Template: docs/SIMTemplateAPI.md
147-
- Site: docs/SiteAPI.md
148-
- Site Configuration: docs/SiteConfigurationAPI.md
149-
- Site Template: docs/SiteTemplateAPI.md
150-
- Site Template Configuration: docs/SiteTemplateConfigurationAPI.md
151-
- SSL VPN: docs/SSLVPNAPI.md
152-
- SSO: docs/SSOAPI.md
153-
- Stack: docs/StackAPI.md
154-
- Statistic: docs/StatisticAPI.md
155-
- Switch: docs/SwitchAPI.md
156-
- Switch QoS: docs/SwitchQoSAPI.md
157-
- Switch Template: docs/SwitchTemplateAPI.md
158-
- System Settings: docs/SystemSettingsAPI.md
159-
- Threat Management: docs/ThreatManagementAPI.md
160-
- Topology: docs/TopologyAPI.md
161-
- URL Filtering: docs/URLFilteringAPI.md
162-
- URL Filtering Template: docs/URLFilteringTemplateAPI.md
163-
- User and Role: docs/UserAndRoleAPI.md
164-
- VoIP: docs/VoIPAPI.md
165-
- VoIP Template: docs/VoIPTemplateAPI.md
166-
- Voucher: docs/VoucherAPI.md
167-
- VPN: docs/VPNAPI.md
168-
- VRRP: docs/VRRPAPI.md
169-
- Webhook Setting: docs/WebhookSettingAPI.md
170-
- Wired Network: docs/WiredNetworkAPI.md
171-
- Wired Network Template: docs/WiredNetworkTemplateAPI.md
172-
- WireGuard VPN: docs/WireguardVPNAPI.md
173-
- Wireless IDSIPS: docs/WirelessIDSIPSAPI.md
174-
- Wireless IDSIPS Template: docs/WirelessIDSIPSTemplateAPI.md
175-
- Wireless Network: docs/WirelessNetworkAPI.md
176-
- Wireless Network Template: docs/WirelessNetworkTemplateAPI.md
177-
- WLAN Optimization: docs/WLANOptimizationAPI.md
17828
plugins:
17929
- search
30+
- awesome-nav
18031
- exclude:
18132
glob:
18233
- /.openapi-generator

omada/.nav.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
nav:
2+
- Home: README.md
3+
- API Reference:
4+
- "docs/*API.md"
5+
- Model Reference:
6+
- glob: "docs/*.md"
7+
ignore: "docs/*API.md"

omada/.openapi-generator-ignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,5 @@ git_push.sh
1111
# Travis CI config (not needed)
1212
.travis.yml
1313

14+
# mkdocs-awesome-nav
15+
.nav.yml

0 commit comments

Comments
 (0)