Generate SDK from OpenAPI #264
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Generate SDK from OpenAPI | |
| on: | |
| schedule: | |
| # Run daily at UTC 00:00 (JST 09:00) | |
| - cron: '0 0 * * *' | |
| workflow_dispatch: # For manual execution | |
| jobs: | |
| generate-sdk: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Download OpenAPI specs | |
| run: | | |
| mkdir -p tmp | |
| curl -o tmp/openapi-v1.json https://docs.growi.org/openapi-spec-apiv1.json | |
| curl -o tmp/openapi-v3.json https://docs.growi.org/openapi-spec-apiv3.json | |
| - uses: pnpm/action-setup@v2 | |
| with: | |
| version: 10.11.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - name: Check for changes in OpenAPI specs | |
| id: check_changes | |
| run: | | |
| HAS_CHANGED=$(pnpm run nodets .github/scripts/check-openapi-changes.ts | tail -n 1) | |
| echo "openapi_spec_has_changed=${HAS_CHANGED}" >> $GITHUB_OUTPUT | |
| - name: Overwrite OpenAPI cache | |
| if: steps.check_changes.outputs.openapi_spec_has_changed == 'true' | |
| run: | | |
| mv tmp/openapi-v1.json .openapi-cache/ | |
| mv tmp/openapi-v3.json .openapi-cache/ | |
| - name: Install dependencies | |
| if: steps.check_changes.outputs.openapi_spec_has_changed == 'true' | |
| run: pnpm install | |
| - name: Generate SDK | |
| if: steps.check_changes.outputs.openapi_spec_has_changed == 'true' | |
| run: pnpm run generate:api | |
| - name: Create Changeset for SDK update | |
| if: steps.check_changes.outputs.openapi_spec_has_changed == 'true' | |
| run: | | |
| echo -e "---\n\"@growi/sdk-typescript\": minor\n---\n\nSDK generated from OpenAPI spec update." > .changeset/sdk-update-$(date +%s).md | |
| - name: Create Pull Request | |
| if: steps.check_changes.outputs.openapi_spec_has_changed == 'true' | |
| uses: peter-evans/create-pull-request@v6 | |
| with: | |
| commit-message: 'feat(sdk): generate SDK and add changeset' | |
| title: '⚡️ Generate SDK and add changeset for OpenAPI updates' | |
| body: | | |
| A changeset file has been added for this SDK update. | |
| ## Changes | |
| - Reflected the latest version of OpenAPI specifications | |
| - Regenerated SDK code | |
| - Code formatting with Biome | |
| ## Review checklist | |
| - [ ] Check if breaking changes are included | |
| - [ ] Determine if version update (Major/Minor/Patch) is needed | |
| branch: feat/update-sdk | |
| delete-branch: true | |
| labels: | | |
| sdk-update |