This file contains hidden or 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: Python & Gradle CI/CD | |
| on: | |
| push: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| # Python 설정 | |
| - name: Set up Python | |
| uses: actions/setup-python@v3 | |
| with: | |
| python-version: '3.9' | |
| # Python 패키지 설치 | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| # 테스트 실행 | |
| - name: Run Tests | |
| run: python -m pytest src/test | |
| # EC2에 접속하고 배포 (docker-compose 사용) | |
| - name: Deploy with Docker Compose | |
| uses: appleboy/ssh-action@master | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USERNAME }} | |
| key: ${{ secrets.EC2_SSH_PRIVATE_KEY }} | |
| port: ${{ secrets.EC2_SSH_PORT }} | |
| script: | | |
| cd /home/${{ secrets.EC2_USERNAME }}/app # docker-compose.yml 위치로 이동 | |
| docker-compose down | |
| docker system prune -f | |
| docker-compose pull | |
| docker-compose up -d --build |