feat: chatbot-clova #11
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: Deploy HiDaddy Chatbot | |
| on: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Copy files to EC2 | |
| uses: appleboy/scp-action@v0.1.7 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| port: 22 | |
| source: "./" | |
| target: "/home/ubuntu/hidaddy-ai" | |
| - name: Upload chatbot .env file | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| port: 22 | |
| script: | | |
| set -euo pipefail | |
| echo "${{ secrets.CHATBOT_ENV_FILE }}" > /home/ubuntu/hidaddy-ai/chatbot/.env | |
| chmod 600 /home/ubuntu/hidaddy-ai/chatbot/.env | |
| chown ubuntu:ubuntu /home/ubuntu/hidaddy-ai/chatbot/.env | |
| - name: Install dependencies & restart chatbot | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| port: 22 | |
| script: | | |
| set -euo pipefail | |
| cd /home/ubuntu/hidaddy-ai/chatbot | |
| # Python venv 준비 | |
| python3 -m venv venv 2>/dev/null || true | |
| source venv/bin/activate | |
| # requirements 설치 (chatbot/requirements.txt 우선, 없으면 상위 폴더) | |
| if [ -f requirements.txt ]; then | |
| pip install -U pip | |
| pip install -r requirements.txt | |
| elif [ -f ../requirements.txt ]; then | |
| pip install -U pip | |
| pip install -r ../requirements.txt | |
| fi | |
| # 서비스 재시작 | |
| sudo systemctl daemon-reload | |
| sudo systemctl restart chatbot | |
| sudo systemctl status chatbot --no-pager || true | |
| - name: Health Check - Chatbot | |
| uses: appleboy/ssh-action@v1.0.3 | |
| with: | |
| host: ${{ secrets.EC2_HOST }} | |
| username: ${{ secrets.EC2_USER }} | |
| key: ${{ secrets.EC2_KEY }} | |
| port: 22 | |
| script: | | |
| set -euo pipefail | |
| echo "Chatbot 서버 헬스체크 중..." | |
| for i in {1..10}; do | |
| STATUS=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8000/health || true) | |
| if [ "$STATUS" = "200" ]; then | |
| echo "Chatbot 서버 헬스체크 성공!" | |
| exit 0 | |
| fi | |
| echo "응답 대기... ($i/10)" | |
| sleep 3 | |
| done |