guidly/.gitlab-ci.yml
laruevin 845814c14b fix: use local deploy instead of SSH (runner is on prod server)
The GitLab Runner runs on the same VPS as the production app,
so SSH-ing from the server to itself is unnecessary. This removes
the SSH key dependency and simplifies the deploy stage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-11 12:47:50 +07:00

61 lines
1.5 KiB
YAML

stages:
- lint
- build
- deploy
# Шаблон: установка зависимостей + кэш (shell executor, Node.js на VPS)
.node_setup:
before_script:
- npm ci --prefer-offline
cache:
key:
files:
- package-lock.json
paths:
- node_modules/
# Lint — на каждый push и MR
lint:
extends: .node_setup
stage: lint
script:
- npm run lint
# Build — компиляция TS + Vite сборка
build:
extends: .node_setup
stage: build
script:
- npm run build
artifacts:
paths:
- dist/
- dist-server/
- dist-bot/
expire_in: 1 hour
# Deploy — только при push в main (runner на том же сервере — деплой локальный)
deploy_production:
stage: deploy
dependencies:
- build
script:
- DEPLOY_DIR=/root/guidly
- mkdir -p "$DEPLOY_DIR"/{dist,dist-server,dist-bot,deploy}
- rsync -a --delete dist/ "$DEPLOY_DIR/dist/"
- rsync -a --delete dist-server/ "$DEPLOY_DIR/dist-server/"
- rsync -a --delete dist-bot/ "$DEPLOY_DIR/dist-bot/"
- cp -f package.json package-lock.json ecosystem.config.cjs "$DEPLOY_DIR/"
- cp -f deploy/nginx-guidly.conf "$DEPLOY_DIR/deploy/" 2>/dev/null || true
- cd "$DEPLOY_DIR"
- npm install --omit=dev
- pm2 delete guidly-server 2>/dev/null || true
- pm2 start ecosystem.config.cjs
- pm2 save
- echo "=== Deploy complete ==="
rules:
- if: $CI_COMMIT_BRANCH == "main"
environment:
name: production
url: https://gidli.ru