Skip to content

Commit 48313c3

Browse files
authored
Merge pull request #7 from darjeeling/main
deploy
2 parents c342c1b + 784054e commit 48313c3

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: pk web site backend deployment
2+
3+
on:
4+
workflow_run:
5+
workflows: ["pk web site backend testing"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
deploy:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
steps:
14+
- name: executing remote ssh commands for update
15+
uses: appleboy/[email protected]
16+
with:
17+
host: ${{ secrets.HOSTNAME }}
18+
username: ${{ secrets.USERNAME }}
19+
key: ${{ secrets.KEY }}
20+
script:
21+
cd python.or.kr && git pull
22+
23+
- name: executing remote ssh commands for deployment
24+
uses: appleboy/[email protected]
25+
with:
26+
host: ${{ secrets.HOSTNAME }}
27+
username: ${{ secrets.USERNAME }}
28+
key: ${{ secrets.KEY }}
29+
script:
30+
cd python.or.kr && bash deploy_prod.sh
31+

.github/workflows/testing.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# The name of the action
2-
name: pao web site backend testing
2+
name: pk web site backend testing
33
# When the action is triggered
44
on:
55
push:

deploy_prod.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
PID_FILE="/home/pk/pk.pid"
4+
LOG_DIR="/home/pk/logs"
5+
6+
cd ~/
7+
cd python.or.kr
8+
# shutdown exist gunicorn
9+
if [ -f ${PID_FILE} ]; then
10+
PID=$(cat $PID_FILE)
11+
kill -TERM $PID
12+
rm ${PID_FILE}
13+
fi
14+
15+
mkdir -p ${LOG_DIR}
16+
17+
# update changes before update
18+
# git pull
19+
source .venv/bin/activate
20+
uv sync
21+
cd pythonkr_backend
22+
export DJANGO_SETTINGS_MODULE="pythonkr_backend.settings.prod"
23+
./manage.py migrate --no-input
24+
./manage.py collectstatic --clear --noinput
25+
gunicorn --workers=2 \
26+
-b :2026 \
27+
--access-logfile ${LOG_DIR}/access.log \
28+
--error-logfile ${LOG_DIR}/error.log \
29+
--daemon \
30+
--pid ${PID_FILE} \
31+
pythonkr_backend.wsgi

0 commit comments

Comments
 (0)