Files
usbcheck.it/.gitlab-ci.yml

91 lines
1.9 KiB
YAML

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 node_modules für schnellere Builds
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
# 1) Dependencies installieren
install:
stage: install
<<: *node_pnpm
script:
- echo "📦 Installing deps..."
- 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
# 2) Build erzeugen
build:
stage: build
<<: *node_pnpm
script:
- echo "🏗️ Building..."
- pnpm build
- echo "✅ Build complete."
artifacts:
paths:
- ${BUILD_DIR}/
expire_in: 1 week
# 3) Template für FTPS-Deploy (lftp)
.deploy_ftps_template: &deploy_ftps
stage: deploy
image: alpine:3.20
before_script:
- echo "📡 Installing lftp..."
- apk add --no-cache lftp
script:
- echo "🚀 Deploy via FTPS to $FTP_HOST:$FTP_PATH ..."
- lftp -e "
set ftp:passive-mode true;
set ssl:verify-certificate no;
open -u $FTP_USER,$FTP_PASSWORD $FTP_HOST;
mirror -R --delete --parallel=4 ${BUILD_DIR}/ $FTP_PATH;
bye
"
- echo "✅ Deploy finished."
# 3a) Staging-Deployment
deploy:staging:
<<: *deploy_ftps
variables:
FTP_PATH: $FTP_PATH_STAGING
environment:
name: staging
url: https://staging.usbcheck.it
only:
- develop
- merge_requests
# 3b) Production-Deployment
deploy:production:
<<: *deploy_ftps
variables:
FTP_PATH: $FTP_PATH_PROD
environment:
name: production
url: https://www.usbcheck.it
only:
- main
when: manual