-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (45 loc) · 1.67 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
name: Deploy to Production
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout the code
uses: actions/checkout@v3
- name: Set up SSH
uses: webfactory/ssh-agent@v0.5.3
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Add server to known_hosts
run: |
ssh-keyscan 154.38.183.197 >> ~/.ssh/known_hosts
- name: Deploy to server
run: |
ssh root@154.38.183.197 << 'EOF'
cd /var/www/santensor/ESPB_Portafolio
# Cargar nvm correctamente
export NVM_DIR="/root/.nvm"
. "$NVM_DIR/nvm.sh" # Cargar nvm de manera explícita
# Verifica que node y npm están disponibles
node -v
npm -v
# Descarta cualquier cambio local no comprometido para evitar conflictos con el git pull
git reset --hard
# Obtener los últimos cambios del repositorio
git pull origin main
# Frontend: instalar dependencias y generar el build de producción
cd frontend
npm install # Ahora que nvm está cargado, npm funcionará
npm run build
# Backend: activar el entorno virtual correcto y manejar dependencias y migraciones
source /var/www/santensor/ESPB_Portafolio/venv/bin/activate # Usar el entorno correcto
cd ../backend
pip install -r requirements.txt
python manage.py migrate
# Reiniciar servicios
sudo systemctl restart daphne
sudo systemctl reload nginx
EOF