diff --git a/.github/workflows/cd-dev.yml b/.github/workflows/cd-dev.yml new file mode 100644 index 0000000..661c466 --- /dev/null +++ b/.github/workflows/cd-dev.yml @@ -0,0 +1,53 @@ +name: CD - Dev + +on: + workflow_dispatch: + push: + branches: + - dev + +jobs: + build: + name: Build & Push Docker Image + runs-on: ubuntu-latest + + steps: + - name: Discord Notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} + uses: Ilshidur/action-discord@master + with: + args: + '📈 AI predict 서버 배포 시작' + + # 코드 체크아웃 + - name: Checkout repository + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: SSH to EC2 and deploy + uses: appleboy/ssh-action@v1.2.0 + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.EC2_SSH_KEY }} + script: | + cd ai-predict-server + git pull + sudo docker stop weathertago-ai-server || true + sudo docker rm -f weathertago-ai-server || true + sudo docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/weathertago-ai-server:latest . + sudo docker run -d --name weathertago-ai-server -p 8000:8000 ${{ secrets.DOCKER_HUB_USERNAME }}/weathertago-ai-server:latest + env: + ACTIONS_RUNNER_DEBUG: true + + + - name: Discord Notification + env: + DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }} + uses: Ilshidur/action-discord@master + with: + args: + '😎 AI predict 서버 배포 완료됨' +