Skip to content

Commit 3717bb4

Browse files
committed
first vps commit
1 parent 13e01d4 commit 3717bb4

1 file changed

Lines changed: 13 additions & 40 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -5,50 +5,23 @@ on:
55
branches: [back]
66

77
jobs:
8-
deploy:
8+
deploy-backend:
99
runs-on: self-hosted
10-
steps:
11-
- name: Clone or pull
12-
run: |
13-
REPO="https://github.com/AnywayHack/FinTech_Hack.git"
14-
DIR="$HOME/hackathon/backend"
15-
if [ -d "$DIR/.git" ]; then
16-
cd "$DIR"
17-
git fetch origin
18-
git checkout back
19-
git reset --hard origin/back
20-
else
21-
git clone -b back "$REPO" "$DIR"
22-
fi
23-
24-
- name: Setup venv if missing
25-
run: |
26-
if [ ! -d "$HOME/hackathon/.venv" ]; then
27-
python3.11 -m venv "$HOME/hackathon/.venv"
28-
fi
2910

30-
- name: Install deps
31-
run: |
32-
source "$HOME/hackathon/.venv/bin/activate"
33-
pip install --upgrade pip
34-
pip install -r "$HOME/hackathon/backend/requirements.txt"
11+
steps:
12+
- uses: actions/checkout@v4
13+
with:
14+
ref: back
3515

36-
- name: Stop old service
16+
- name: Copy backend to app directory
3717
run: |
38-
pkill -f "uvicorn app.main:app.*8001" || true
39-
sleep 2
18+
rsync -a --exclude='venv' --exclude='__pycache__' \
19+
$GITHUB_WORKSPACE/ /var/www/myapp/backend/
4020
41-
- name: Start service
21+
- name: Install backend dependencies
4222
run: |
43-
cd "$HOME/hackathon/backend"
44-
source "$HOME/hackathon/.venv/bin/activate"
45-
nohup uvicorn app.main:app --host 0.0.0.0 --port 8001 \
46-
> "$HOME/hackathon/backend/uvicorn.log" \
47-
2> "$HOME/hackathon/backend/uvicorn_err.log" &
48-
disown
49-
sleep 5
23+
source /var/www/myapp/backend/venv/bin/activate
24+
pip install -r /var/www/myapp/backend/requirements.txt
5025
51-
- name: Health check
52-
run: |
53-
curl -fsS http://localhost:8001/health || exit 1
54-
echo "Backend is healthy!!!"
26+
- name: Restart FastAPI
27+
run: sudo systemctl restart myapp

0 commit comments

Comments
 (0)