Files
habit-tracker/.gitea/workflows/ci-cd.yml
T
shinalok c0d14967d0
CI/CD / test (push) Successful in 51s
CI/CD / deploy (push) Failing after 1m0s
update CI/CD workflow: install development dependencies for testing with pip
2026-08-07 19:31:07 +09:00

65 lines
1.8 KiB
YAML

name: CI/CD
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: 저장소 체크아웃
uses: actions/checkout@v4
- name: Python 3.13 설치
uses: actions/setup-python@v5
with:
python-version: '3.13'
- name: 테스트용 .env 준비
run: |
cat > .env <<'EOF'
SECRET_KEY=ci-dummy-secret-key
DATABASE_URL=sqlite:///./ci.db
EOF
- name: 의존성 설치
run: pip install -e ".[dev]"
- name: pytest 실행
run: pytest
deploy:
needs: test
if: gitea.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: 저장소 체크아웃
uses: actions/checkout@v4
- name: ssh/rsync 설치
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends openssh-client rsync
- name: SSH 키 준비
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -p ${{ vars.DEPLOY_SSH_PORT }} ${{ vars.DEPLOY_SSH_HOST }} >> ~/.ssh/known_hosts
- name: 소스 동기화
run: |
rsync -avz \
--exclude='.env' --exclude='media' --exclude='__pycache__' \
-e "ssh -p ${{ vars.DEPLOY_SSH_PORT }}" \
pyproject.toml alembic.ini Dockerfile docker-compose.yml app migrations scripts \
${{ vars.DEPLOY_SSH_USER }}@${{ vars.DEPLOY_SSH_HOST }}:${{ vars.DEPLOY_REMOTE_PATH }}/
- name: 컨테이너 재빌드 & 재시작
run: |
ssh -p ${{ vars.DEPLOY_SSH_PORT }} ${{ vars.DEPLOY_SSH_USER }}@${{ vars.DEPLOY_SSH_HOST }} \
"cd ${{ vars.DEPLOY_REMOTE_PATH }} && docker compose build && docker compose up -d"