-
Notifications
You must be signed in to change notification settings - Fork 0
97 lines (83 loc) · 2.88 KB
/
sync-api.yml
File metadata and controls
97 lines (83 loc) · 2.88 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
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 }}