Skip to content

Commit 69a823c

Browse files
authored
Add deployment workflow for EC2 using SSH
1 parent 9cbfa1f commit 69a823c

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Deploy a EC2
2+
3+
on:
4+
push:
5+
branches:
6+
- produccion
7+
8+
jobs:
9+
deploy:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Deploy via SSH
14+
uses: appleboy/ssh-action@v1.0.0
15+
with:
16+
host: ${{ secrets.EC2_HOST }}
17+
username: ${{ secrets.EC2_USER }}
18+
key: ${{ secrets.EC2_KEY }}
19+
script: |
20+
sudo systemctl start mysql || true
21+
sudo fuser -k 8080/tcp || true
22+
sudo fuser -k 80/tcp || true
23+
24+
cd "/home/ubuntu/Desktop/Proyecto/Proyecto"
25+
git pull origin produccion
26+
27+
cd "/home/ubuntu/Desktop/Proyecto/Proyecto/API (SpringBoot)/Proyecto/"
28+
chmod +x mvnw
29+
nohup ./mvnw spring-boot:run > /home/ubuntu/backend.log 2>&1 &
30+
31+
cd /home/ubuntu/Desktop/Proyecto/Proyecto/Frontend/
32+
sudo nohup php artisan serve --host=0.0.0.0 --port=80 > /home/ubuntu/frontend.log 2>&1 &

0 commit comments

Comments
 (0)