Sync Infra Specs #50
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 Infra Specs | |
| on: | |
| schedule: | |
| - cron: "18 15 * * *" | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| jobs: | |
| sync-specs: | |
| runs-on: ubuntu-24.04 | |
| steps: | |
| - name: Generate GitHub App installation token | |
| id: app-token | |
| uses: actions/create-github-app-token@v2 | |
| with: | |
| app-id: ${{ vars.AUTOFIXER_APP_ID }} | |
| private-key: ${{ secrets.AUTOFIXER_APP_SECRET }} | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Download latest infra OpenAPI specs | |
| run: | | |
| curl -f -L https://raw.githubusercontent.com/e2b-dev/infra/refs/heads/main/spec/openapi.yml -o spec/openapi.infra.yaml | |
| curl -f -L https://raw.githubusercontent.com/e2b-dev/infra/refs/heads/main/spec/openapi-dashboard.yml -o spec/openapi.dashboard-api.yaml | |
| - name: Check for spec changes | |
| id: check-spec-changes | |
| run: | | |
| if [[ -z $(git status --porcelain spec/openapi.infra.yaml spec/openapi.dashboard-api.yaml) ]]; then | |
| echo "No changes detected in infra specs." | |
| echo "has_changes=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Changes detected in infra specs." | |
| echo "has_changes=true" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup Bun | |
| if: steps.check-spec-changes.outputs.has_changes == 'true' | |
| uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: "1.2.0" | |
| - name: Install dependencies | |
| if: steps.check-spec-changes.outputs.has_changes == 'true' | |
| run: bun install --frozen-lockfile | |
| - name: Regenerate API types | |
| if: steps.check-spec-changes.outputs.has_changes == 'true' | |
| run: | | |
| bun run generate:infra | |
| bun run generate:dashboard-api | |
| - name: Autofix generated type files | |
| if: steps.check-spec-changes.outputs.has_changes == 'true' | |
| run: | | |
| GENERATED_TYPE_FILES=$(git diff --name-only -- src/types/infra-api.types.ts src/types/dashboard-api.types.ts | tr '\n' ' ') | |
| if [[ -z "${GENERATED_TYPE_FILES}" ]]; then | |
| echo "No generated type changes detected; skipping autofix." | |
| exit 0 | |
| fi | |
| echo "Running format/lint autofix on generated types: ${GENERATED_TYPE_FILES}" | |
| bunx biome format --write ${GENERATED_TYPE_FILES} | |
| bunx biome lint --write ${GENERATED_TYPE_FILES} | |
| - name: Create Pull Request | |
| if: steps.check-spec-changes.outputs.has_changes == 'true' | |
| uses: peter-evans/create-pull-request@v7 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| commit-message: "chore: sync infra OpenAPI specs" | |
| title: "chore: sync infra OpenAPI specs" | |
| body: | | |
| This PR syncs OpenAPI specs from [e2b-dev/infra](https://github.com/e2b-dev/infra): | |
| - `spec/openapi.infra.yaml` | |
| - `spec/openapi.dashboard-api.yaml` | |
| It also regenerates dependent TypeScript API types and applies formatting/lint autofixes. | |
| --- | |
| *This PR was automatically created by the sync-infra-specs workflow.* | |
| branch: chore/sync-infra-specs | |
| delete-branch: true |