name: CI on: push: branches: [main, dev] pull_request: branches: [main, dev] workflow_dispatch: jobs: lint-typecheck: name: Lint & Typecheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 with: version: '9.15.4' - uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile - name: Typecheck run: pnpm typecheck - name: Lint run: pnpm lint test: name: Test runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 with: version: '9.15.4' - uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile - name: Run tests run: pnpm test build: name: Build runs-on: ubuntu-latest needs: [lint-typecheck, test] steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 with: version: '9.15.4' - uses: actions/setup-node@v4 with: node-version: 20 cache: pnpm - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build all packages env: VITE_API_URL: "" run: pnpm build docker: name: Build & Push Docker Images runs-on: ubuntu-latest needs: [build] outputs: tag: ${{ steps.version.outputs.tag }} steps: - uses: actions/checkout@v4 - name: Generate image tag id: version run: | # Always include short SHA so each build is immutable and cache-from can never # cross-contaminate between commits. For PRs the format is pr-N-sha7; for main # it is YYYY.MM.DD-sha7. if [ "${{ github.event_name }}" = "pull_request" ]; then TAG="pr-${{ github.event.pull_request.number }}-${GITHUB_SHA::7}" else TAG="$(date -u +%Y.%m.%d)-${GITHUB_SHA::7}" fi echo "tag=$TAG" >> "$GITHUB_OUTPUT" echo "Image tag: $TAG" - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Log in to Gitea Container Registry uses: docker/login-action@v3 with: registry: git.farh.net username: ${{ gitea.actor }} password: ${{ secrets.REGISTRY_TOKEN }} - name: Build and push API image uses: docker/build-push-action@v6 with: context: . file: apps/api/Dockerfile target: runner push: true tags: | git.farh.net/groombook/api:${{ steps.version.outputs.tag }} ${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/api:latest' || '' }} cache-from: type=registry,ref=git.farh.net/groombook/cache:api cache-to: type=registry,ref=git.farh.net/groombook/cache:api,mode=max - name: Build and push Migrate image uses: docker/build-push-action@v6 with: context: . file: apps/api/Dockerfile target: migrate push: true tags: | git.farh.net/groombook/migrate:${{ steps.version.outputs.tag }} ${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/migrate:latest' || '' }} cache-from: type=registry,ref=git.farh.net/groombook/cache:migrate cache-to: type=registry,ref=git.farh.net/groombook/cache:migrate,mode=max - name: Build and push Seed image uses: docker/build-push-action@v6 with: context: . file: apps/api/Dockerfile target: seed push: true tags: | git.farh.net/groombook/seed:${{ steps.version.outputs.tag }} ${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/seed:latest' || '' }} cache-from: type=registry,ref=git.farh.net/groombook/cache:seed cache-to: type=registry,ref=git.farh.net/groombook/cache:seed,mode=max - name: Build and push Reset image uses: docker/build-push-action@v6 with: context: . file: apps/api/Dockerfile target: reset push: true tags: | git.farh.net/groombook/reset:${{ steps.version.outputs.tag }} ${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/reset:latest' || '' }} cache-from: type=registry,ref=git.farh.net/groombook/cache:reset cache-to: type=registry,ref=git.farh.net/groombook/cache:reset,mode=max - name: Build and push Web image uses: docker/build-push-action@v6 with: context: . file: apps/web/Dockerfile push: true tags: | git.farh.net/groombook/web:${{ steps.version.outputs.tag }} ${{ github.ref == 'refs/heads/main' && 'git.farh.net/groombook/web:latest' || '' }} cache-from: type=registry,ref=git.farh.net/groombook/cache:web cache-to: type=registry,ref=git.farh.net/groombook/cache:web,mode=max deploy-dev: name: Deploy PR to groombook-dev runs-on: runners-groombook needs: [docker] if: github.event_name == 'pull_request' steps: - name: Install kubectl run: | curl -sLO "https://dl.k8s.io/release/$(curl -sL https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" chmod +x kubectl sudo mv kubectl /usr/local/bin/ kubectl version --client - name: Deploy to groombook-dev env: PR_NUM: ${{ github.event.pull_request.number }} SHA: ${{ github.sha }} run: | TAG="pr-$PR_NUM-${SHA::7}" echo "Deploying images tagged $TAG to groombook-dev..." kubectl delete job "migrate-pr-$PR_NUM" -n groombook-dev --ignore-not-found cat <