Files
usbcheck.it/.gitlab-ci.yml

129 lines
3.5 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 (z.B. Astro)
# Deploy: FTPS (lftp) → all-inkl
# -----------------------------------------
stages:
- install
- build
- deploy
variables:
NODE_ENV: production
# Falls dein Build woanders hin schreibt (z.B. "build" oder ".output/public"):
# HIER anpassen!
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. 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. Projekt bauen
# -----------------------------------------
build:
stage: build
<<: *node_pnpm
dependencies:
- install
script:
- echo "🏗️ Building..."
- pnpm build
- echo "📂 Build-Output (Top-Level):"
- ls -la
- echo "📂 Inhalt von ${BUILD_DIR} (falls vorhanden):"
- if [ -d "${BUILD_DIR}" ]; then ls -la "${BUILD_DIR}"; else echo "⚠️ Verzeichnis ${BUILD_DIR} existiert NICHT!"; fi
- 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 # <<< ganz wichtig: lade Artefakte vom Build-Job
before_script:
- echo "📡 Installing lftp..."
- apk add --no-cache lftp
- echo "📂 Dateien im CI-Workspace vor Deploy:"
- pwd
- ls -la
- echo "📂 Inhalt von ${BUILD_DIR} (Deploy-Job):"
- if [ -d "${BUILD_DIR}" ]; then ls -la "${BUILD_DIR}"; else echo "❌ ${BUILD_DIR} existiert HIER nicht!"; fi
script:
- if [ ! -d "${BUILD_DIR}" ]; then echo "❌ Abbruch: Build-Verzeichnis ${BUILD_DIR} fehlt im Deploy-Job."; exit 1; fi
- 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