guidly/.gitlab-ci.yml
laruevin 9960f0cc78 ci: switch to shell executor for GitLab Runner
Remove Docker image references since runner uses shell executor
with Node.js installed directly on VPS.

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

68 lines
1.6 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
deploy_production:
stage: deploy
dependencies:
- build
before_script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
- mkdir -p ~/.ssh
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- chmod 644 ~/.ssh/known_hosts
script:
- tar -czf deploy.tar.gz dist/ dist-server/ dist-bot/ package.json package-lock.json ecosystem.config.cjs deploy/nginx-guidly.conf
- scp deploy.tar.gz "${DEPLOY_USER}@${DEPLOY_HOST}:/tmp/"
- |
ssh "${DEPLOY_USER}@${DEPLOY_HOST}" << 'ENDSSH'
set -e
cd /root/guidly
tar -xzf /tmp/deploy.tar.gz
rm /tmp/deploy.tar.gz
npm install --omit=dev
pm2 delete guidly-server 2>/dev/null || true
pm2 start ecosystem.config.cjs
pm2 save
echo "=== Deploy complete ==="
ENDSSH
rules:
- if: $CI_COMMIT_BRANCH == "main"
environment:
name: production
url: https://gidli.ru