Files
usbcheck.it/.gitlab-ci.yml

117 lines
2.8 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# -----------------------------------------
# USBcheck.it GitLab CI/CD Pipeline
# Build: pnpm
# Deploy: FTPS (lftp) → all-inkl
# -----------------------------------------
stages:
- install
- build
- deploy
variables:
NODE_ENV: production
BUILD_DIR: dist
# -----------------------------------------
# Gemeinsames Setup für Node + pnpm
# -----------------------------------------
.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 für node_modules
# -----------------------------------------
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
# -----------------------------------------
# 1. Install dependencies
# -----------------------------------------
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 project
# -----------------------------------------
build:
stage: build
<<: *node_pnpm
dependencies:
- install
script:
- echo "🏗️ Building..."
- pnpm build
- echo "✅ Build complete."
artifacts:
paths:
- ${BUILD_DIR}/
expire_in: 1 week
# -----------------------------------------
# 3. Template für FTPS Deployment
# -----------------------------------------
.deploy_ftps_template: &deploy_ftps
stage: deploy
image: alpine:3.20
dependencies:
- build # <<< sehr wichtig: Lade Build-Artefakte
before_script:
- echo "📡 Installing lftp..."
- apk add --no-cache lftp
script:
- echo "🚀 Deploy via FTPS to $FTP_HOST:$FTP_PATH ..."
- lftp -e "
set ftp:ssl-force true;
set ftp:passive-mode true;
set ftp:ssl-protect-data 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