build: serve ui.hanzo.ai from our own stack #699
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: CI | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - develop | |
| pull_request: | |
| branches: | |
| - main | |
| - develop | |
| workflow_dispatch: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: hanzo-build-linux-amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Run linting | |
| run: pnpm run lint | |
| typecheck: | |
| name: Type Check | |
| runs-on: hanzo-build-linux-amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build UI package | |
| run: cd pkgs/ui && pnpm run build | |
| - name: Run type checking | |
| run: | | |
| cd app && pnpm run typecheck | |
| cd ../pkgs/ui && pnpm run tc --noEmit | |
| build: | |
| name: Build | |
| runs-on: hanzo-build-linux-amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Build UI package | |
| run: cd pkgs/ui && pnpm run build:full | |
| - name: Build app | |
| run: cd app && pnpm run build | |
| env: | |
| NEXT_PUBLIC_APP_URL: https://ui.hanzo.ai | |
| - name: Upload build artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: | | |
| app/.next | |
| pkgs/ui/dist | |
| test: | |
| name: Test | |
| runs-on: hanzo-build-linux-amd64 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --no-frozen-lockfile | |
| - name: Run pkgs/ui tests | |
| run: cd pkgs/ui && pnpm test -- --run | |
| - name: Run app tests | |
| run: | | |
| if [ -f "app/package.json" ] && grep -q '"test"' app/package.json 2>/dev/null; then | |
| cd app && pnpm test || echo "No tests configured" | |
| else | |
| echo "No test script found" | |
| fi | |
| - name: Upload coverage | |
| if: always() | |
| uses: codecov/codecov-action@v3 | |
| with: | |
| files: ./pkgs/ui/coverage/lcov.info | |
| flags: unit | |
| deploy-preview: | |
| name: Deploy Preview | |
| runs-on: hanzo-deploy-linux-amd64 | |
| needs: [lint, typecheck, build] | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v3 | |
| with: | |
| version: 9 | |
| - name: Install Vercel CLI | |
| run: npm install --global vercel@latest | |
| - name: Pull Vercel Environment Information | |
| run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
| - name: Build Project Artifacts | |
| run: vercel build --token=${{ secrets.VERCEL_TOKEN }} | |
| - name: Deploy Project Artifacts to Vercel | |
| id: deploy | |
| run: | | |
| url=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}) | |
| echo "preview_url=$url" >> $GITHUB_OUTPUT | |
| - name: Comment PR with preview URL | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: '🚀 Preview deployed to: ${{ steps.deploy.outputs.preview_url }}' | |
| }) | |
| status: | |
| name: CI Status | |
| runs-on: hanzo-build-linux-amd64 | |
| needs: [lint, typecheck, build, test] | |
| if: always() | |
| steps: | |
| - name: Check status | |
| run: | | |
| if [ "${{ needs.lint.result }}" != "success" ] || \ | |
| [ "${{ needs.typecheck.result }}" != "success" ] || \ | |
| [ "${{ needs.build.result }}" != "success" ] || \ | |
| [ "${{ needs.test.result }}" != "success" ]; then | |
| echo "CI checks failed" | |
| exit 1 | |
| else | |
| echo "All CI checks passed!" | |
| fi |