Files
usbcheck.it/.gitlab-ci.yml

146 lines
3.9 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.
stages:
- install
- build
- deploy
variables:
NODE_ENV: production
BUILD_DIR: dist
# -----------------------------------------
# 1. Dependencies installieren
# -----------------------------------------
install:
stage: install
image: node:20-bullseye
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
script:
- echo "📦 Installing deps..."
- corepack enable
- corepack prepare pnpm@9.12.0 --activate
- pnpm -v
- |
if [ -f pnpm-lock.yaml ]; then
echo "pnpm-lock.yaml gefunden nutze --frozen-lockfile"
pnpm install --frozen-lockfile --reporter=append-only
else
echo "Keine pnpm-lock.yaml normales pnpm install"
pnpm install --reporter=append-only
fi
artifacts:
paths:
- node_modules/
expire_in: 1h
# -----------------------------------------
# 2. Projekt bauen
# -----------------------------------------
build:
stage: build
image: node:20-bullseye
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- node_modules/
dependencies:
- install
script:
- echo "🏗️ Building..."
- corepack enable
- corepack prepare pnpm@9.12.0 --activate
- pnpm -v
- 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
# -----------------------------------------
# 3a. Staging Deployment via FTPS
# -----------------------------------------
deploy:staging:
stage: deploy
image: alpine:3.20
dependencies:
- build
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} im 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_STAGING} ..."
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_STAGING}; bye"
echo '✅ Deploy finished (staging).'
environment:
name: staging
url: https://staging.usbcheck.it
only:
- develop
- merge_requests
# -----------------------------------------
# 3b. Production Deployment via FTPS
# -----------------------------------------
deploy:production:
stage: deploy
image: alpine:3.20
dependencies:
- build
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} im 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_PROD} ..."
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_PROD}; bye"
echo '✅ Deploy finished (production).'
environment:
name: production
url: https://www.usbcheck.it
only:
- main
when: manual