1+ name : Generate SDK
2+
3+ on :
4+ workflow_dispatch :
5+ inputs :
6+ create_pr :
7+ description : ' Create PR if changes are detected'
8+ type : boolean
9+ default : true
10+ target_branch :
11+ description : ' Target branch for PR (default: main)'
12+ type : string
13+ default : ' main'
14+ schedule :
15+ # Run weekly on Mondays at 9 AM UTC
16+ - cron : ' 0 9 * * 1'
17+
18+ permissions :
19+ contents : write
20+ pull-requests : write
21+
22+ jobs :
23+ generate :
24+ runs-on : ubuntu-latest
25+ steps :
26+ - name : Checkout repository
27+ uses : actions/checkout@v4
28+ with :
29+ token : ${{ secrets.GITHUB_TOKEN }}
30+
31+ - name : Setup Python
32+ uses : actions/setup-python@v4
33+ with :
34+ python-version : ' 3.9'
35+
36+ - name : Install UV
37+ uses : astral-sh/setup-uv@v3
38+
39+ - name : Install Python dependencies
40+ run : |
41+ uv sync --dev
42+
43+ - name : Install Speakeasy CLI
44+ run : |
45+ curl -fsSL https://raw.githubusercontent.com/speakeasy-api/speakeasy/main/install.sh | sh
46+ echo "$HOME/.speakeasy/bin" >> $GITHUB_PATH
47+
48+ - name : Verify Speakeasy installation
49+ run : speakeasy --version
50+
51+ - name : Generate SDK
52+ env :
53+ SPEAKEASY_API_KEY : ${{ secrets.SPEAKEASY_API_KEY }}
54+ run : |
55+ # Run the full generation process
56+ make generate
57+
58+ - name : Check for changes
59+ id : changes
60+ run : |
61+ if [ -n "$(git status --porcelain)" ]; then
62+ echo "changes=true" >> $GITHUB_OUTPUT
63+ echo "Changes detected:"
64+ git status --porcelain
65+ else
66+ echo "changes=false" >> $GITHUB_OUTPUT
67+ echo "No changes detected"
68+ fi
69+
70+ - name : Create Pull Request
71+ if : steps.changes.outputs.changes == 'true' && (github.event.inputs.create_pr == 'true' || github.event_name == 'schedule')
72+ env :
73+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
74+ run : |
75+ # Configure git
76+ git config --global user.name "opper-bot"
77+ git config --global user.email "bot@opper.ai"
78+
79+ # Create a new branch with timestamp
80+ BRANCH_NAME="sdk-update-$(date +%Y%m%d-%H%M%S)"
81+ git checkout -b "$BRANCH_NAME"
82+
83+ # Stage and commit changes
84+ git add .
85+ git commit -m "chore: update SDK via automated generation
86+
87+ - Run speakeasy generation
88+ - Apply parameter name fixes
89+ - Apply schema conversion patches
90+
91+ Generated on: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
92+
93+ 🤖 This PR was created automatically by the SDK generation workflow."
94+
95+ # Push the branch
96+ git push origin "$BRANCH_NAME"
97+
98+ # Create PR
99+ TARGET_BRANCH="${{ github.event.inputs.target_branch || 'main' }}"
100+ gh pr create \
101+ --title "🔄 Automated SDK Update - $(date +%Y-%m-%d)" \
102+ --body "$(cat <<'EOF'
103+ ## 🤖 Automated SDK Generation
104+
105+ This PR contains updates from the latest SDK generation run.
106+
107+ ### Changes Made
108+ - ✅ Speakeasy SDK generation
109+ - ✅ Parameter name fixes (input_ → input)
110+ - ✅ Schema conversion patches applied
111+
112+ ### Generated Files
113+ The following files were automatically generated/updated:
114+ - `src/opperai/`
115+ - `docs/`
116+ - `README.md`
117+ - `USAGE.md`
118+
119+ ### Review Checklist
120+ - [ ] Generated code looks correct
121+ - [ ] Examples still work
122+ - [ ] No breaking changes in public API
123+ - [ ] Version bump needed? (if so, update pyproject.toml)
124+
125+ ---
126+
127+ Generated on: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
128+
129+ 🤖 Created by automated workflow
130+ EOF
131+ )" \
132+ --base "$TARGET_BRANCH" \
133+ --head "$BRANCH_NAME" \
134+ --label "automated" \
135+ --label "sdk-update"
136+
137+ - name : Summary
138+ run : |
139+ if [ "${{ steps.changes.outputs.changes }}" == "true" ]; then
140+ echo "✅ SDK generation completed with changes"
141+ if [ "${{ github.event.inputs.create_pr }}" == "true" ] || [ "${{ github.event_name }}" == "schedule" ]; then
142+ echo "📝 Pull request created"
143+ else
144+ echo "⚠️ Changes detected but PR creation skipped"
145+ fi
146+ else
147+ echo "✅ SDK generation completed - no changes needed"
148+ fi
0 commit comments