fix: 무조건 안 도와주는 버그 #1
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: FastAPI LangChain CI/CD Pipeline | |
| on: | |
| push: | |
| branches: | |
| - main # main 브랜치에 푸시될 때마다 이 워크플로우가 실행됩니다. | |
| pull_request: | |
| branches: | |
| - main # main 브랜치에 PR을 만들 때마다 실행 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 1. Checkout repository | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| # 2. Set up Python environment | |
| - name: Set up Python 3.11 | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.11' # 사용하고 있는 Python 버전 | |
| # 3. Install dependencies | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| # 4. Run tests | |
| - name: Run tests | |
| run: | | |
| pytest # pytest를 사용해 테스트 실행, 다른 테스트 도구를 사용할 수 있음 | |
| dockerize: | |
| runs-on: ubuntu-latest | |
| needs: build # build job이 성공적으로 완료된 후에 실행됨 | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v2 | |
| # 1. Build Docker image | |
| - name: Build Docker image | |
| run: | | |
| docker build -t fastapi-langchain . | |
| # 2. Push Docker image to Docker Hub (옵션) | |
| - name: Push Docker image to Docker Hub | |
| run: | | |
| echo ${{ secrets.DOCKER_PASSWORD }} | docker login --username ${{ secrets.DOCKER_USERNAME }} --password-stdin | |
| docker push fastapi-langchain | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: dockerize # dockerize job이 완료된 후 실행 | |
| steps: | |
| - name: Deploy to Server | |
| run: | | |
| # 배포 스크립트를 추가하거나, 서버에 SSH로 접속해 FastAPI 앱을 배포하는 명령어 추가 | |
| ssh user@your-server "docker pull fastapi-langchain && docker run -d -p 80:80 fastapi-langchain" |