File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Deploy to server
2+
3+ on :
4+ push :
5+ branches : [ main, deploy-workflow ]
6+
7+ jobs :
8+ build-and-deploy :
9+ runs-on : ubuntu-latest
10+
11+ steps :
12+ - name : Checkout
13+ uses : actions/checkout@v4
14+
15+ - name : Setup SSH
16+ run : |
17+ mkdir -p ~/.ssh
18+ echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa
19+ chmod 600 ~/.ssh/id_rsa
20+ ssh-keyscan -H "${{ secrets.SERVER_IP }}" >> ~/.ssh/known_hosts
21+
22+ - name : Ensure destination directory exists
23+ run : |
24+ ssh -o StrictHostKeyChecking=yes \
25+ "${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }}" \
26+ "mkdir -p '${{ secrets.PROJECT_PATH }}'"
27+
28+ - name : Upload entire repository (preserve venv on server)
29+ run : |
30+ rsync -az --delete \
31+ --exclude='venv/' \
32+ -e "ssh -o StrictHostKeyChecking=yes" \
33+ ./ \
34+ "${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }}:${{ secrets.PROJECT_PATH }}/"
35+
36+ - name : Install deps and restart service on server
37+ run : |
38+ ssh -o StrictHostKeyChecking=yes \
39+ "${{ secrets.USERNAME }}@${{ secrets.SERVER_IP }}" <<'EOF'
40+ set -euo pipefail
41+ cd "${{ secrets.PROJECT_PATH }}"
42+ # Activate existing venv and install/upgrade deps
43+ source "${{ secrets.PROJECT_PATH }}/venv/bin/activate"
44+ pip3 install --upgrade pip
45+ pip3 install -r requirements.txt
46+ # Restart your service
47+ sudo systemctl restart parktrack-api-server
48+ EOF
Original file line number Diff line number Diff line change 33
44def main ():
55 api_server = PublicAPI (db_manager = DBManager ("mock" ))
6- api_server .run (URL (host = "0 .0.0.0 " , port = 8000 ))
6+ api_server .run (URL (host = "127 .0.0.1 " , port = 8000 ))
77
88if __name__ == "__main__" :
99 main ()
You can’t perform that action at this time.
0 commit comments