Fix: logger fixed #75
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Django CI/CD | |
on: | |
push: | |
branches: [main] | |
pull_request: | |
branches: [main] | |
jobs: | |
#CI pipeline | |
build: | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 4 | |
matrix: | |
python-version: ['3.10', '3.11'] | |
steps: | |
#코드 체크아웃 | |
- uses: actions/checkout@v4 | |
#파이썬 설정 | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# pip 캐시 추가 | |
- name: Cache pip dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('**/backend/requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
#의존성 설치 | |
- name: Install Dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r backend/requirements.txt | |
#테스트 실행 | |
- name: Run Tests | |
run: | | |
cd backend/worklog | |
python manage.py test auth | |
python manage.py test profiles | |
#빌드 실패 시 오류 보고 후 정지 | |
- name: Report Build Failure | |
if: failure() | |
run: echo "Build failed. Skipping deployment." | |
continue-on-error: false | |
#CD pipeline | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
if: success() | |
steps: | |
#AWS EC2로 배포 | |
- name: Deploy to EC2 | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.EC2_HOST }} | |
username: ${{ secrets.EC2_USER }} | |
key: ${{ secrets.EC2_SSH_KEY }} | |
script: | | |
cd worklog/backend/ | |
git fetch origin | |
git reset --hard origin/main | |
cd ../.. | |
source worklogvenv/bin/activate | |
cd worklog/backend/ | |
pip install -r requirements.txt | |
cd worklog/ | |
python manage.py makemigrations | |
python manage.py migrate | |
python manage.py collectstatic --noinput | |
sudo systemctl restart gunicorn |