chore: migrate from GitLab CI to Gitea Actions
Replace .gitlab-ci.yml with .gitea/workflows/ci.yml. Same pipeline: lint → build → deploy (local, runner on prod server). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4f5cbaee39
commit
3f5f1d463e
59
.gitea/workflows/ci.yml
Normal file
59
.gitea/workflows/ci.yml
Normal file
@ -0,0 +1,59 @@
|
||||
name: CI/CD
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run lint
|
||||
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
needs: lint
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: gitea.ref == 'refs/heads/main'
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 22
|
||||
cache: npm
|
||||
- run: npm ci
|
||||
- run: npm run build
|
||||
- name: Deploy to production
|
||||
run: |
|
||||
DEPLOY_DIR=/root/guidly
|
||||
sudo mkdir -p "$DEPLOY_DIR"/{dist,dist-server,dist-bot,deploy}
|
||||
sudo rsync -a --delete dist/ "$DEPLOY_DIR/dist/"
|
||||
sudo rsync -a --delete dist-server/ "$DEPLOY_DIR/dist-server/"
|
||||
sudo rsync -a --delete dist-bot/ "$DEPLOY_DIR/dist-bot/"
|
||||
sudo cp -f package.json package-lock.json ecosystem.config.cjs "$DEPLOY_DIR/"
|
||||
sudo cp -f deploy/nginx-guidly.conf "$DEPLOY_DIR/deploy/" 2>/dev/null || true
|
||||
cd "$DEPLOY_DIR"
|
||||
sudo npm install --omit=dev
|
||||
sudo pm2 delete guidly-server 2>/dev/null || true
|
||||
sudo pm2 start ecosystem.config.cjs
|
||||
sudo pm2 save
|
||||
echo "=== Deploy complete ==="
|
||||
@ -1,60 +0,0 @@
|
||||
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
|
||||
- sudo mkdir -p "$DEPLOY_DIR"/{dist,dist-server,dist-bot,deploy}
|
||||
- sudo rsync -a --delete dist/ "$DEPLOY_DIR/dist/"
|
||||
- sudo rsync -a --delete dist-server/ "$DEPLOY_DIR/dist-server/"
|
||||
- sudo rsync -a --delete dist-bot/ "$DEPLOY_DIR/dist-bot/"
|
||||
- sudo cp -f package.json package-lock.json ecosystem.config.cjs "$DEPLOY_DIR/"
|
||||
- sudo cp -f deploy/nginx-guidly.conf "$DEPLOY_DIR/deploy/" 2>/dev/null || true
|
||||
- cd "$DEPLOY_DIR"
|
||||
- sudo npm install --omit=dev
|
||||
- sudo pm2 delete guidly-server 2>/dev/null || true
|
||||
- sudo pm2 start ecosystem.config.cjs
|
||||
- sudo pm2 save
|
||||
- echo "=== Deploy complete ==="
|
||||
rules:
|
||||
- if: $CI_COMMIT_BRANCH == "main"
|
||||
environment:
|
||||
name: production
|
||||
url: https://gidli.ru
|
||||
Loading…
Reference in New Issue
Block a user