Files
usbcheck.it/.gitlab-ci.yml

103 lines
2.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:
- deploy
variables:
NODE_ENV: production
BUILD_DIR: dist
# -----------------------------------------
# Staging: baut & deployed in einem Job
# -----------------------------------------
deploy:staging:
stage: deploy
image: node:20-bullseye
script:
- |
set -e
echo "📦 Install & Build (staging)..."
apt-get update && apt-get install -y lftp
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
pnpm build
echo "📂 Build-Output (Top-Level):"
ls -la
echo "📂 Inhalt von ${BUILD_DIR}:"
if [ -d "${BUILD_DIR}" ]; then
ls -la "${BUILD_DIR}"
else
echo "❌ Verzeichnis ${BUILD_DIR} existiert NICHT Abbruch."
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
# -----------------------------------------
# Production: baut & deployed in einem Job
# -----------------------------------------
deploy:production:
stage: deploy
image: node:20-bullseye
script:
- |
set -e
echo "📦 Install & Build (production)..."
apt-get update && apt-get install -y lftp
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
pnpm build
echo "📂 Build-Output (Top-Level):"
ls -la
echo "📂 Inhalt von ${BUILD_DIR}:"
if [ -d "${BUILD_DIR}" ]; then
ls -la "${BUILD_DIR}"
else
echo "❌ Verzeichnis ${BUILD_DIR} existiert NICHT Abbruch."
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