Build Stainless SDKs #14
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: Build Stainless SDKs | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - 'app/api/e2/**' | |
| - 'stainless.yml' | |
| workflow_dispatch: | |
| concurrency: | |
| group: stainless-sdk-${{ github.ref }} | |
| cancel-in-progress: true | |
| env: | |
| STAINLESS_PROJECT: inbound | |
| MINTLIFY_PROJECT_ID: 684319e452e43891b702c525 | |
| jobs: | |
| build-sdk: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Bun | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - name: Install dependencies | |
| run: bun install | |
| - name: Validate stainless.yml against schema | |
| run: | | |
| pip install check-jsonschema | |
| check-jsonschema --schemafile https://app.stainless.com/config.schema.json stainless.yml | |
| echo "✅ stainless.yml is valid" | |
| - name: Generate OpenAPI spec | |
| run: | | |
| bun run generate:openapi | |
| echo "=== Spec Summary ===" | |
| jq '{title: .info.title, version: .info.version, paths: (.paths | keys | length)}' public/openapi.json | |
| - name: Upload to Stainless | |
| id: stainless | |
| uses: stainless-api/upload-openapi-spec-action/build@v1 | |
| with: | |
| stainless_api_key: ${{ secrets.STAINLESS_API_KEY }} | |
| project: ${{ env.STAINLESS_PROJECT }} | |
| oas_path: public/openapi.json | |
| config_path: stainless.yml | |
| - name: Install Stainless CLI | |
| run: | | |
| curl -fsSL https://app.stainless.com/install.sh | sh | |
| echo "$HOME/.stainless/bin" >> $GITHUB_PATH | |
| - name: Poll for build completion | |
| env: | |
| STAINLESS_API_KEY: ${{ secrets.STAINLESS_API_KEY }} | |
| run: | | |
| echo "Polling for build completion..." | |
| BUILD_ID="${{ steps.stainless.outputs.build_id }}" | |
| if [ -z "$BUILD_ID" ]; then | |
| echo "No build ID returned, waiting 60s as fallback..." | |
| sleep 60 | |
| exit 0 | |
| fi | |
| echo "Build ID: $BUILD_ID" | |
| for i in {1..30}; do | |
| status=$(stl builds retrieve "$BUILD_ID" --project "${{ env.STAINLESS_PROJECT }}" --json 2>/dev/null | jq -r '.status // "unknown"' || echo "pending") | |
| echo "Attempt $i: Status = $status" | |
| case "$status" in | |
| "completed"|"success") | |
| echo "✅ Build completed successfully!" | |
| exit 0 | |
| ;; | |
| "failed"|"error") | |
| echo "❌ Build failed!" | |
| exit 1 | |
| ;; | |
| *) | |
| sleep 10 | |
| ;; | |
| esac | |
| done | |
| echo "⚠️ Timeout waiting for build, proceeding anyway..." | |
| - name: Trigger Mintlify documentation update | |
| run: | | |
| echo "Triggering Mintlify documentation update..." | |
| response=$(curl -s -w "\n%{http_code}" -X POST \ | |
| "https://api.mintlify.com/v1/project/update/${{ env.MINTLIFY_PROJECT_ID }}" \ | |
| -H "Authorization: Bearer ${{ secrets.MINTLIFY_API_KEY }}" \ | |
| -H "Content-Type: application/json") | |
| http_code=$(echo "$response" | tail -n1) | |
| body=$(echo "$response" | sed '$d') | |
| echo "Response: $body" | |
| echo "HTTP Status: $http_code" | |
| if [ "$http_code" = "202" ]; then | |
| echo "✅ Mintlify update triggered successfully" | |
| status_id=$(echo "$body" | jq -r '.statusId // empty') | |
| if [ -n "$status_id" ]; then | |
| echo "Status ID: $status_id" | |
| fi | |
| else | |
| echo "⚠️ Failed to trigger Mintlify update (HTTP $http_code)" | |
| echo "This is non-blocking - docs will update on next push to docs branch" | |
| fi |