name: Frontend Web - Build & Lint on: push: branches: [main, pre-prod] paths: - "frontend-prep/**" pull_request: branches: [main, pre-prod] paths: - "frontend-prep/**" jobs: build: 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 & lint working-directory: frontend-prep run: | npx tsc -b --noEmit npm run lint - name: Build working-directory: frontend-prep env: VITE_TOMTOM_API_KEY: ${{ secrets.VITE_TOMTOM_API_KEY }} run: npm run build - name: Login to Docker Hub if: github.event_name == 'push' || github.event_name == 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Set up Docker Buildx if: github.event_name == 'push' || github.event_name == 'pull_request' uses: docker/setup-buildx-action@v3 - name: Build & push frontend if: github.event_name == 'push' || github.event_name == 'pull_request' uses: docker/build-push-action@v6 with: context: . file: docker-pre-prod/frontend/Dockerfile push: true tags: xor1234/frontend-mln:${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'latest' || 'pre-prod' }} build-args: | VITE_TOMTOM_API_KEY=${{ secrets.VITE_TOMTOM_API_KEY }} - name: SSH Deploy if: github.event_name == 'push' uses: appleboy/ssh-action@v1 with: host: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.SERVER_HOST_PROD || secrets.SERVER_HOST_PRE_PROD }} username: ${{ secrets.SERVER_USER }} key: ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.SERVER_SSH_KEY_PROD || secrets.SERVER_SSH_KEY_PRE_PROD }} script: | docker compose -f ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.COMPOSE_PATH_PROD || secrets.COMPOSE_PATH_PRE_PROD }} pull frontend docker compose -f ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && secrets.COMPOSE_PATH_PROD || secrets.COMPOSE_PATH_PRE_PROD }} up -d --no-deps frontend