From 031b8096f4e74e93b22a85ffbbb0070f1d5bb671 Mon Sep 17 00:00:00 2001 From: rocknroll Date: Mon, 7 Oct 2024 01:56:50 +0900 Subject: [PATCH] Testing github action --- .github/workflows/deploy.yaml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/deploy.yaml diff --git a/.github/workflows/deploy.yaml b/.github/workflows/deploy.yaml new file mode 100644 index 0000000..dba9e8d --- /dev/null +++ b/.github/workflows/deploy.yaml @@ -0,0 +1,30 @@ +name: Deploy FastAPI + +on: + push: + branches: + - main # main 브랜치에 커밋이 푸시될 때마다 실행됩니다. + +jobs: + deploy: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Set up SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} + + - name: Deploy to EC2 + run: | + ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF' + cd /planner # FastAPI 프로젝트 디렉토리로 이동 + git pull origin main # 최신 커밋 가져오기 + cd /Controller + source myenv/bin/activate # 가상 환경 활성화 (필요한 경우) + pip install -r requirements.txt # 의존성 설치 + uvicorn main:app --host 0.0.0.0 --port 1500 --reload & # FastAPI 서버 시작 + EOF