-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (46 loc) · 1.34 KB
/
Copy pathpython-app.yml
File metadata and controls
55 lines (46 loc) · 1.34 KB
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
name: CI/CD Pipeline
on:
push:
workflow_dispatch:
jobs:
build:
name: Stage 1 - Build
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Build
run: echo "Building the application..."
test:
name: Stage 2 - Test
runs-on: ubuntu-latest
needs: build
steps:
- name: Run Tests
run: echo "Running tests..."
deploy:
name: Stage 3 - Deploy (Manual Approval)
runs-on: ubuntu-latest
needs: test
environment:
name: production
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Deploy to EC2
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
port: 22
script: |
echo "[+] Pulling latest code from GitHub..."
cd /home/ubuntu/git-github
git pull origin main
git reset --hard origin/main
echo "[+] Killing any existing process on port 8000..."
fuser -k 8000/tcp || true
echo "[+] Starting Python app in background..."
nohup python3 app/main.py > app.log 2>&1 &
echo "[+] Deployment complete. App should be live at http://${{ secrets.EC2_HOST }}:8000"