name: Deploy VConnect API on: push: branches: - main workflow_dispatch: # 수동 실행 가능 jobs: test: name: Test runs-on: ubuntu-latest steps: - name: Checkout code uses: actions/checkout@v3 - name: Set up Python uses: actions/setup-python@v4 with: python-version: '3.10' - name: Install dependencies run: | pip install --upgrade pip pip install -r requirements.txt - name: Run tests run: | echo "테스트 실행 중..." # pytest가 있다면: pytest python -m pytest || echo "테스트 스킵" deploy: name: Deploy to Server runs-on: ubuntu-latest needs: test # test 성공 후 실행 if: github.ref == 'refs/heads/main' steps: - name: Deploy via SSH run: | echo "배포 시작..." # SSH 설정 후 주석 해제: # mkdir -p ~/.ssh # echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa # chmod 600 ~/.ssh/id_rsa # ssh-keyscan -H 192.168.0.97 >> ~/.ssh/known_hosts # ssh user@192.168.0.97 "cd /path/to/vconnect-api && git pull && systemctl restart vconnect-api" echo "배포 완료!"