stages: [install, build, deploy] variables: NODE_ENV: production BUILD_DIR: dist # Gemeinsames pnpm-Setup für alle Node-Jobs .node_pnpm: &node_pnpm image: node:20-bullseye before_script: - echo "🧩 Corepack/Pnpm aktivieren..." - corepack enable - corepack prepare pnpm@9.12.0 --activate - pnpm -v cache: key: ${CI_COMMIT_REF_SLUG} paths: - node_modules/ install: stage: install <<: *node_pnpm script: - echo "📦 Installing deps..." # Nutze --frozen-lockfile nur, wenn pnpm-lock.yaml im Repo committed ist - if [ -f pnpm-lock.yaml ]; then pnpm install --frozen-lockfile --reporter=append-only; else pnpm install --reporter=append-only; fi artifacts: paths: - node_modules/ expire_in: 1h build: stage: build <<: *node_pnpm script: - echo "🏗️ Building..." - pnpm build - echo "✅ Build complete." artifacts: paths: - ${BUILD_DIR}/ expire_in: 1 week .deploy_template: &deploy stage: deploy image: alpine:3.20 before_script: - 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: - rsync -az --delete ${BUILD_DIR}/ $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH deploy:staging: <<: *deploy variables: DEPLOY_PATH: /www/htdocs/w020df28/projects/usbcheck/staging/ environment: name: staging url: https://staging.usbcheck.it only: - develop - merge_requests deploy:production: <<: *deploy variables: DEPLOY_PATH: /www/htdocs/w020df28/projects/usbcheck/web/ environment: name: production url: https://www.usbcheck.it only: - main when: manual