name: Frontend Web - Build & Lint on: push: branches: [pre-prod] paths: - "frontend-prep/**" - "docker/frontend/**" pull_request: branches: [pre-prod] paths: - "frontend-prep/**" - "docker/frontend/**" jobs: lint-typecheck: name: Lint & Typecheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm cache-dependency-path: frontend-prep/package-lock.json - name: Install dependencies working-directory: frontend-prep run: npm ci - name: Typecheck working-directory: frontend-prep run: npx tsc -b --noEmit - name: Lint working-directory: frontend-prep run: npm run lint build: name: Build needs: lint-typecheck runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node.js uses: actions/setup-node@v4 with: node-version: 20 cache: npm cache-dependency-path: frontend-prep/package-lock.json - name: Install dependencies working-directory: frontend-prep run: npm ci - name: Build working-directory: frontend-prep env: VITE_TOMTOM_API_KEY: ${{ secrets.VITE_TOMTOM_API_KEY }} run: npm run build docker: name: Docker Build & Push needs: build runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod' steps: - uses: actions/checkout@v4 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build & push frontend uses: docker/build-push-action@v6 with: context: . file: docker/frontend/Dockerfile push: true tags: xor1234/frontend-mln:latest build-args: | VITE_TOMTOM_API_KEY=${{ secrets.VITE_TOMTOM_API_KEY }} deploy: name: Deploy to server needs: docker runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/pre-prod' steps: - name: SSH deploy uses: appleboy/ssh-action@v1 with: host: ${{ secrets.SERVER_HOST }} username: ${{ secrets.SERVER_USER }} key: ${{ secrets.SERVER_SSH_KEY }} script: | docker compose -f ${{ secrets.COMPOSE_PATH }} pull frontend docker compose -f ${{ secrets.COMPOSE_PATH }} up -d --no-deps frontend