-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (49 loc) · 1.81 KB
/
balbambalbam-run-ai-server.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
59
60
61
62
name: Balbambalbam-Server-EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy to EC2
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: 22
script: |
sudo apt-get update
sudo apt-get install -y python3-pip python3-venv git
REPO_DIR="$HOME/balbambalbam-ai-server/"
if [ ! -d "$REPO_DIR" ]; then
git clone https://github.com/Capstone-4Potato/ai-server.git "$REPO_DIR"
fi
cd "$REPO_DIR"
git pull origin main
PRJ_DIR="${REPO_DIR}balbambalbam-ai-server/"
cd "$PRJ_DIR"
echo "NAVER_TTS_API_ID=${{ secrets.NAVER_TTS_API_ID }}" > .env
echo "NAVER_TTS_API_SECRET=${{ secrets.NAVER_TTS_API_SECRET }}" >> .env
if [ ! -d ".venv" ]; then
python3 -m venv .venv
fi
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
nohup uvicorn app:app --host 0.0.0.0 --port 5000 --reload >> ai-server.log 2>&1 &
sleep 10
if ! pgrep -f "uvicorn app:app"; then
echo "Error: Uvicorn failed to start. Check ai-server.log for details." | tee -a ~/deploy.log
exit 1
else
echo "Uvicorn started successfully." | tee -a ~/deploy.log
fi
TEST_DIR="${PRJ_DIR}test/"
cd "$TEST_DIR"
output=$(python3 sys_con_test.py)
echo "$output" | tee -a ~/deploy.log