feat: add Redis cache, gzip, CI/CD via Gitea self-hosted runner
This commit is contained in:
31
.github/workflows/ci.yml
vendored
Normal file
31
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
name: CI - Build and Lint
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, develop]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
- name: Generate Prisma client
|
||||
run: npx prisma generate
|
||||
|
||||
- name: Lint
|
||||
run: npm run lint --if-present || true
|
||||
|
||||
- name: Build
|
||||
run: npm run build
|
||||
|
||||
- name: Verify build output
|
||||
run: |
|
||||
[ -d dist ] && echo "✅ Build OK" || (echo "❌ dist not found" && exit 1)
|
||||
47
.github/workflows/deploy.yml
vendored
47
.github/workflows/deploy.yml
vendored
@@ -1,4 +1,4 @@
|
||||
name: Deploy API Ubigeo
|
||||
name: Deploy API-Ubigeo
|
||||
|
||||
on:
|
||||
push:
|
||||
@@ -6,40 +6,25 @@ on:
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: self-hosted
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Deploy al VPS via SSH
|
||||
uses: appleboy/ssh-action@v1.0.3
|
||||
with:
|
||||
host: 158.220.106.131
|
||||
username: root
|
||||
password: ${{ secrets.VPS_PASSWORD }}
|
||||
script: |
|
||||
set -e
|
||||
cd /home/deployer/api-ubigeo || (mkdir -p /home/deployer/api-ubigeo && cd /home/deployer/api-ubigeo)
|
||||
- name: Copy source to server
|
||||
run: |
|
||||
rsync -av --delete \
|
||||
--exclude='.git' \
|
||||
--exclude='node_modules' \
|
||||
--exclude='dist' \
|
||||
--exclude='.env' \
|
||||
. /home/deployer/api-ubigeo/
|
||||
|
||||
# Pull o clone
|
||||
if [ -d ".git" ]; then
|
||||
git pull origin main
|
||||
else
|
||||
git clone https://github.com/${{ github.repository }} .
|
||||
fi
|
||||
- name: Build & deploy
|
||||
run: bash /home/deployer/deploy-ubigeo.sh
|
||||
|
||||
# Build imagen
|
||||
docker build -t ubigeo-api:latest .
|
||||
|
||||
# Deploy con compose
|
||||
docker compose -f docker-compose.production.yml up -d --force-recreate api
|
||||
|
||||
# Ejecutar migraciones
|
||||
docker exec ubigeo-api npx prisma migrate deploy
|
||||
|
||||
# Verificar health
|
||||
sleep 10
|
||||
curl -f http://localhost:3200/api/v1/health || exit 1
|
||||
|
||||
echo "✅ Deploy exitoso"
|
||||
- name: Health check
|
||||
run: |
|
||||
sleep 10
|
||||
curl -f https://api-ubigeo.darkcodex.dev/api/v1/health || exit 1
|
||||
|
||||
Reference in New Issue
Block a user