Skip to content

Commit cf91da8

Browse files
committed
Deploy workflow
1 parent b593e51 commit cf91da8

2 files changed

Lines changed: 49 additions & 1 deletion

File tree

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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

src/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
def 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

88
if __name__ == "__main__":
99
main()

0 commit comments

Comments
 (0)