letsss gooo again 2 #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Backend | |
| on: | |
| push: | |
| branches: [back] | |
| jobs: | |
| deploy: | |
| runs-on: self-hosted | |
| steps: | |
| - name: Clone or pull | |
| run: | | |
| REPO="https://github.com/Al-Zhilin/FinTech_Hack.git" | |
| DIR="$HOME/hackathon/backend" | |
| if [ -d "$DIR/.git" ]; then | |
| cd "$DIR" | |
| git fetch origin | |
| git checkout back | |
| git reset --hard origin/back | |
| else | |
| git clone -b back "$REPO" "$DIR" | |
| fi | |
| - name: Setup venv if missing | |
| run: | | |
| if [ ! -d "$HOME/hackathon/.venv" ]; then | |
| python3.11 -m venv "$HOME/hackathon/.venv" | |
| fi | |
| - name: Install deps | |
| run: | | |
| source "$HOME/hackathon/.venv/bin/activate" | |
| pip install --upgrade pip | |
| pip install -r "$HOME/hackathon/backend/requirements.txt" | |
| - name: Stop old service | |
| run: | | |
| pkill -f "uvicorn app.main:app.*8001" || true | |
| sleep 2 | |
| - name: Start service | |
| run: | | |
| cd "$HOME/hackathon/backend" | |
| source "$HOME/hackathon/.venv/bin/activate" | |
| nohup uvicorn app.main:app --host 0.0.0.0 --port 8001 \ | |
| > "$HOME/hackathon/backend/uvicorn.log" \ | |
| 2> "$HOME/hackathon/backend/uvicorn_err.log" & | |
| disown | |
| sleep 5 | |
| - name: Health check | |
| run: | | |
| curl -fsS http://localhost:8001/health || exit 1 | |
| echo "Backend is healthy!!!" |