Skip to content

deploy #7

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: pk web site backend deployment

on:
workflow_run:
workflows: ["pk web site backend testing"]
types:
- completed

jobs:
deploy:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: executing remote ssh commands for update
uses: appleboy/ssh-action@v1.2.1
with:
host: ${{ secrets.HOSTNAME }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script:
cd python.or.kr && git pull

- name: executing remote ssh commands for deployment
uses: appleboy/ssh-action@v1.2.1
with:
host: ${{ secrets.HOSTNAME }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
script:
cd python.or.kr && bash deploy_prod.sh

2 changes: 1 addition & 1 deletion .github/workflows/testing.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The name of the action
name: pao web site backend testing
name: pk web site backend testing
# When the action is triggered
on:
push:
Expand Down
31 changes: 31 additions & 0 deletions deploy_prod.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env bash

PID_FILE="/home/pk/pk.pid"
LOG_DIR="/home/pk/logs"

cd ~/
cd python.or.kr
# shutdown exist gunicorn
if [ -f ${PID_FILE} ]; then
PID=$(cat $PID_FILE)
kill -TERM $PID
rm ${PID_FILE}
fi

mkdir -p ${LOG_DIR}

# update changes before update
# git pull
source .venv/bin/activate
uv sync
cd pythonkr_backend
export DJANGO_SETTINGS_MODULE="pythonkr_backend.settings.prod"
./manage.py migrate --no-input
./manage.py collectstatic --clear --noinput
gunicorn --workers=2 \
-b :2026 \
--access-logfile ${LOG_DIR}/access.log \
--error-logfile ${LOG_DIR}/error.log \
--daemon \
--pid ${PID_FILE} \
pythonkr_backend.wsgi