Merge pull request #45 from MJU-TranScore/develop #47
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: Flask CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - develop | |
| - master | |
| pull_request: | |
| branches: | |
| - develop | |
| - master | |
| jobs: | |
| ci: | |
| name: CI (Test Only) | |
| if: | | |
| (github.event_name == 'push' && github.ref == 'refs/heads/develop') || | |
| (github.event_name == 'pull_request' && github.base_ref == 'develop') | |
| 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.12.10" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Run tests | |
| run: | | |
| echo "pytest 테스트 여기에 추가할 수 있음" | |
| # 예: pytest | |
| cd: | |
| name: CD (Deploy to Server) | |
| if: | | |
| (github.event_name == 'push' && github.ref == 'refs/heads/master') || | |
| (github.event_name == 'pull_request' && github.base_ref == 'master') | |
| 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.12.10" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Deploy to EC2 Server | |
| uses: appleboy/ssh-action@v0.1.6 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ubuntu | |
| key: ${{ secrets.EC2_SSH_KEY }} | |
| script: | | |
| cd /home/ubuntu/transcore-backend | |
| git pull origin master | |
| source venv/bin/activate | |
| pip install -r requirements.txt | |
| sudo systemctl restart transcore |