Skip to content
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

CI/CD 구현 #114

Merged
merged 9 commits into from
Oct 3, 2024
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
28 changes: 28 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Main CD

on:
push:
branches:
- main

jobs:
cd:
runs-on: ubuntu-latest
steps:
- name: 서버 배포
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.key }}
script: |
set -e
cd /home/ubuntu/weaverse/weaverse-backend/
git pull origin main

source venv/bin/activate
pip install -r requirements.txt

python manage.py collectstatic --noinput

sudo systemctl restart weaverse
46 changes: 46 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Dev CI

on:
pull_request:
branches:
- dev
- main

jobs:
ci:
runs-on: ubuntu-latest

services:
postgres:
image: postgres:latest
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: postgres
ports:
- 5432:5432

steps:
- name: 체크아웃 레포지토리
uses: actions/checkout@v3

- name: 파이썬 설정
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: 의존성 설치
run: |
python -m pip install --upgrade pip
pip install --upgrade pip
pip install -r requirements.txt

- name: github scrests를 사용하여 환경 변수 복사
run: |
echo "SECRET_KEY=${{ secrets.env }}" >> .env
- name: migrate 실행
run: |
python manage.py migrate
- name: 테스트 실행
run: |
python manage.py test
8 changes: 4 additions & 4 deletions accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
app_name = "accounts"

urlpatterns = [
path("users/", views.user_list_create, name="user-list-create"),
path("users/<int:pk>/", views.user_retrieve_update_delete, name="user-detail"),
path("users/counts/", views.user_count, name="user-count"),
path("managers/", views.manager_list_create, name="manager-list-create"),
path("users/", views.student_list_create, name="user-list-create"),
path("users/<int:pk>/", views.student_retrieve_update_delete, name="user-detail"),
path("users/counts/", views.student_count, name="user-count"),
path("managers/", views.tutor_list_create, name="manager-list-create"),
]
5 changes: 3 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@ mypy==1.11.2
mypy-extensions==1.0.0
packaging==24.1
pillow==10.4.0
pip==24.0
pluggy==1.5.0
psycopg-binary==3.2.2
pip==24.0
PyJWT==2.9.0
psycopg==3.2.2
psycopg-binary==3.2.2
pycparser==2.22
pytest==8.3.3
pytest-django==4.9.0
Expand Down
11 changes: 11 additions & 0 deletions weaverse/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,17 @@
USE_TZ = True

STATIC_URL = "static/"
STATIC_ROOT = os.getenv("STATIC_ROOT", BASE_DIR / "static")

STATICFILES_DIRS = os.getenv("STATICFILES_DIRS")
if STATICFILES_DIRS:
STATICFILES_DIRS = [path.strip() for path in STATICFILES_DIRS.split(",")]
else:
STATICFILES_DIRS = [BASE_DIR / "staticfiles"]

CSRF_TRUSTED_ORIGINS = [
"https://www.weaverse.site",
]

DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField"

Expand Down
Loading