# ------------------------------- # USBcheck.it – GitLab CI/CD Setup # ------------------------------- # Features: # - Build static site (Astro, Hugo, Next, etc.) # - Deploys via SSH to all-inkl (staging + production) # - Separate environments for safety # ------------------------------- stages: - install - build - deploy variables: NODE_ENV: production # Directory where the static site is built BUILD_DIR: dist # Cache node_modules for faster builds cache: key: ${CI_COMMIT_REF_SLUG} paths: - node_modules/ # ------------------------------- # 1. Install dependencies # ------------------------------- install: stage: install image: node:20-bullseye script: - echo "🧩 Installing dependencies..." - corepack enable - corepack prepare pnpm@latest --activate - pnpm install --frozen-lockfile --reporter=append-only artifacts: paths: - node_modules/ expire_in: 1h # ------------------------------- # 2. Build project # ------------------------------- build: stage: build image: node:20-bullseye script: - echo "🏗️ Building project..." - pnpm build - echo "✅ Build complete." artifacts: paths: - ${BUILD_DIR}/ expire_in: 1 week # ------------------------------- # 3. Deployment template # ------------------------------- .deploy_template: &deploy stage: deploy image: alpine:3.20 before_script: - echo "🚀 Preparing SSH..." - apk add --no-cache openssh-client rsync - mkdir -p ~/.ssh - echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_ed25519 - chmod 600 ~/.ssh/id_ed25519 - ssh-keyscan -H "$DEPLOY_HOST" >> ~/.ssh/known_hosts script: - echo "🔄 Deploying to $DEPLOY_PATH ..." - rsync -az --delete ${BUILD_DIR}/ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH - echo "✅ Deployment complete." only: [] # ------------------------------- # 3a. Staging deployment # ------------------------------- deploy:staging: <<: *deploy variables: DEPLOY_PATH: /www/htdocs/w020df28/projects/usbcheck/staging/ environment: name: staging url: https://staging.usbcheck.it only: - develop - merge_requests # ------------------------------- # 3b. Production deployment # ------------------------------- deploy:production: <<: *deploy variables: DEPLOY_PATH: /www/htdocs/w020df28/projects/usbcheck/web/ environment: name: production url: https://www.usbcheck.it only: - main when: manual