Update to new common, fixing several bugs #41
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: Generate OpenAPI Types | |
| on: | |
| push: | |
| branches: [main, openapi-staging] | |
| jobs: | |
| generate-openapi: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: 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 --ignore-scripts | |
| - name: Generate OpenAPI types | |
| run: bun run generate:openapi | |
| - name: Deploy to target branch | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Map source branch to target orphan branch | |
| if [ "${{ github.ref_name }}" = "main" ]; then | |
| TARGET_BRANCH="openapi-types" | |
| else | |
| TARGET_BRANCH="openapi-types-staging" | |
| fi | |
| # Store files outside the repo temporarily | |
| cp e2e-out/openapi-server-types.ts /tmp/openapi-server-types.ts | |
| cp e2e-out/kompakkt-api-helpers.ts /tmp/kompakkt-api-helpers.ts | |
| cp e2e-out/package.json /tmp/package.json | |
| # Create orphan branch (index is populated with all files from source — must be cleared) | |
| git checkout --orphan "$TARGET_BRANCH" | |
| # Remove all staged files from the index (they were inherited from source) | |
| git rm -rf --cached . | |
| # Remove all working-tree files except .git | |
| find . -maxdepth 1 -not -name . -not -name .git -exec rm -rf {} + | |
| # Move files back from temp | |
| mv /tmp/openapi-server-types.ts . | |
| mv /tmp/kompakkt-api-helpers.ts . | |
| mv /tmp/package.json . | |
| git add openapi-server-types.ts kompakkt-api-helpers.ts package.json | |
| git diff --staged --quiet || git commit -m "chore: update openapi types [skip ci]" | |
| git push --force origin "$TARGET_BRANCH" |