ci: generate frontend API client from committed OpenAPI contract #3186
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: Frontend CI | |
| on: | |
| push: | |
| branches: | |
| - "**" | |
| tags: | |
| - "v*.*.*" | |
| pull_request: | |
| permissions: | |
| contents: read | |
| jobs: | |
| frontend: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| packages: write | |
| defaults: | |
| run: | |
| working-directory: frontend | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 | |
| with: | |
| node-version: "24" | |
| cache: "npm" | |
| cache-dependency-path: frontend/package-lock.json | |
| - name: Resolve build metadata | |
| run: | | |
| bash ../.github/scripts/resolve_version.sh >> "$GITHUB_ENV" | |
| echo "PUBLIC_REPOSITORY_URL=https://github.com/${GITHUB_REPOSITORY}" >> "$GITHUB_ENV" | |
| - name: Clean install | |
| run: npm run clean-install | |
| - name: Generate API client | |
| run: npm run api:generate | |
| - name: Update third party licenses (Renovate PRs only) | |
| if: > | |
| github.event_name == 'pull_request' && | |
| github.actor == 'renovate[bot]' && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| run: | | |
| npm run licenses:generate | |
| if git diff --exit-code -- LICENSES-THIRD-PARTY.md; then | |
| echo "No changes in LICENSES-THIRD-PARTY.md"; | |
| exit 0; | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add LICENSES-THIRD-PARTY.md | |
| git commit -m "chore: update frontend LICENSES-THIRD-PARTY.md" | |
| git push | |
| - name: Test | |
| run: npm run test | |
| - name: Lint | |
| run: npm run lint | |
| - name: Build | |
| env: | |
| PUBLIC_APP_VERSION: ${{ env.APP_VERSION }} | |
| PUBLIC_COMMIT_SHA: ${{ env.COMMIT_SHA }} | |
| PUBLIC_REPOSITORY_URL: ${{ env.PUBLIC_REPOSITORY_URL }} | |
| run: npm run build | |
| - name: Set up Docker Buildx | |
| if: github.event_name == 'push' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | |
| uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd # v4.0.0 | |
| - name: Log in to GHCR | |
| if: github.event_name == 'push' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | |
| uses: docker/login-action@4907a6ddec9925e35a0a9e82d7399ccc52663121 # v4.1.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract Docker metadata | |
| if: github.event_name == 'push' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | |
| id: meta | |
| uses: docker/metadata-action@030e881283bb7a6894de51c315a6bfe6a94e05cf # v6.0.0 | |
| with: | |
| images: ghcr.io/${{ github.repository }}-frontend | |
| tags: | | |
| # output X.Y.Z | |
| type=semver,pattern={{version}} | |
| # output X.Y | |
| type=semver,pattern={{major}}.{{minor}} | |
| # output X (disabled if major zero) | |
| type=semver,pattern={{major}},enable=${{ !startsWith(github.ref, 'refs/tags/v0.') }} | |
| # output main on default branch | |
| type=raw,value=main,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }} | |
| - name: Build and push image | |
| if: github.event_name == 'push' && (github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || startsWith(github.ref, 'refs/tags/')) | |
| uses: docker/build-push-action@bcafcacb16a39f128d818304e6c9c0c18556b85f # v7.1.0 | |
| with: | |
| context: frontend | |
| file: frontend/Dockerfile | |
| push: true | |
| build-args: | | |
| PUBLIC_APP_VERSION=${{ env.APP_VERSION }} | |
| PUBLIC_COMMIT_SHA=${{ env.COMMIT_SHA }} | |
| PUBLIC_REPOSITORY_URL=${{ env.PUBLIC_REPOSITORY_URL }} | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |