Node.js is already installed on the host runner. actions/checkout@v4 auto-resolves from GitHub. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
48 lines
1.3 KiB
YAML
48 lines
1.3 KiB
YAML
name: CI/CD
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
pull_request:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
lint:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- run: npm ci
|
|
- run: npm run lint
|
|
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
needs: lint
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- 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
|
|
- 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 ==="
|