Skip to content

Commit

Permalink
Deploy test
Browse files Browse the repository at this point in the history
  • Loading branch information
basshamut committed Jun 24, 2024
1 parent 8b777b0 commit 7f7ac08
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14' # O la versión que uses
node-version: '22' # O la versión que uses

- name: Install dependencies
run: |
Expand All @@ -34,27 +34,32 @@ jobs:
env:
SSH_HOST: ${{ secrets.VPS_SSH_HOST }}
SSH_USERNAME: ${{ secrets.VPS_SSH_USERNAME }}
SSH_PASSWORD: ${{ secrets.VPS_SSH_PASSWORD }}
SSH_KEY: ${{ secrets.VPS_SSH_KEY }}
run: |
sudo apt-get install -y sshpass
# Crear un archivo de clave SSH temporal
echo "$SSH_KEY" > /tmp/ssh_key
chmod 600 /tmp/ssh_key
# Crear directorios en el VPS
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$SSH_HOST << 'EOF'
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no $SSH_USERNAME@$SSH_HOST << 'EOF'
mkdir -p /var/www/html/virtual-dojo/frontend
mkdir -p /var/www/html/virtual-dojo/backend
exit
EOF
# Copiar el build del frontend al VPS
sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no -r ./frontend/dist/* $SSH_USERNAME@$SSH_HOST:/var/www/html/virtual-dojo/frontend
scp -i /tmp/ssh_key -o StrictHostKeyChecking=no -r ./frontend/dist/* $SSH_USERNAME@$SSH_HOST:/var/www/html/virtual-dojo/frontend
# Copiar el backend al VPS
sshpass -p "$SSH_PASSWORD" scp -o StrictHostKeyChecking=no -r ./backend/* $SSH_USERNAME@$SSH_HOST:/var/www/html/virtual-dojo/backend
scp -i /tmp/ssh_key -o StrictHostKeyChecking=no -r ./backend/* $SSH_USERNAME@$SSH_HOST:/var/www/html/virtual-dojo/backend
# Conectar al VPS y reiniciar el backend
sshpass -p "$SSH_PASSWORD" ssh -o StrictHostKeyChecking=no $SSH_USERNAME@$SSH_HOST << 'EOF'
ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no $SSH_USERNAME@$SSH_HOST << 'EOF'
cd /var/www/html/virtual-dojo/backend
npm install
pm2 restart all || pm2 start server.js --name virtual-dojo
exit
EOF
# Eliminar el archivo de clave SSH temporal
rm /tmp/ssh_key

0 comments on commit 7f7ac08

Please sign in to comment.