Sync with API #259
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: Sync with API | |
| on: | |
| schedule: | |
| # Run every 6 hours | |
| - cron: "0 */6 * * *" | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: [api-updated] | |
| jobs: | |
| check-api-changes: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| - name: Install uv | |
| run: curl -LsSf https://astral.sh/uv/install.sh | sh | |
| - name: Install dependencies | |
| run: | | |
| uv sync --extra dev | |
| - name: Download latest OpenAPI spec | |
| run: | | |
| curl -o openapi-new.json https://api.rencom.ai/openapi.json | |
| - name: Check for changes | |
| id: diff | |
| run: | | |
| if [ ! -f openapi.json ]; then | |
| echo "No existing spec, this is first run" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| mv openapi-new.json openapi.json | |
| elif ! diff -q openapi.json openapi-new.json; then | |
| echo "OpenAPI spec has changed" | |
| echo "changed=true" >> $GITHUB_OUTPUT | |
| mv openapi-new.json openapi.json | |
| else | |
| echo "No changes detected" | |
| echo "changed=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Regenerate SDK | |
| if: steps.diff.outputs.changed == 'true' | |
| run: | | |
| uv run python scripts/generate.py --spec-url https://api.rencom.ai | |
| - name: Format generated code | |
| if: steps.diff.outputs.changed == 'true' | |
| run: | | |
| uv run ruff format . | |
| - name: Run tests | |
| if: steps.diff.outputs.changed == 'true' | |
| run: | | |
| uv run pytest -m unit | |
| - name: Create Pull Request | |
| if: steps.diff.outputs.changed == 'true' | |
| uses: peter-evans/create-pull-request@v5 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} | |
| commit-message: "chore: sync with API changes" | |
| title: "API Sync: Update generated code" | |
| body: | | |
| Auto-generated PR from API changes detected in OpenAPI spec. | |
| ## Review Checklist | |
| - [ ] Review breaking changes in models | |
| - [ ] Check for new endpoints | |
| - [ ] Verify changed parameters | |
| - [ ] Update CHANGELOG.md if needed | |
| - [ ] Test integration tests pass | |
| - [ ] Update examples if new features added | |
| ## Files Changed | |
| - `openapi.json` - Updated OpenAPI specification | |
| - `rencom/_generated/` - Regenerated code from spec | |
| This PR was automatically created by the sync-api workflow. | |
| Review the changes and merge when ready. | |
| branch: api-sync-${{ github.run_number }} | |
| labels: | | |
| autogenerated | |
| api-sync | |
| assignees: ${{ github.repository_owner }} |