Skip to content

Commit

Permalink
feat: ai 서버 cicd
Browse files Browse the repository at this point in the history
  • Loading branch information
jimin3263 committed May 24, 2024
1 parent 0c4fb46 commit a4d9675
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/fast-api-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: fast api deploy

on:
push:
branches:
- feature/fast-api-cicd
- api-main

env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }}
DOCKERHUB_API_IMAGE_NAME: ${{ secrets.DOCKERHUB_API_IMAGE_NAME }}

jobs:
build:
runs-on: ubuntu-latest

defaults:
run:
working-directory: ./backend-ai-api

steps:
- name: Check Out The Repository
uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.11.9'

- name: Docker build and push
run: |
docker login -u $DOCKERHUB_USERNAME -p $DOCKERHUB_PASSWORD
docker build -t $DOCKERHUB_USERNAME/$DOCKERHUB_API_IMAGE_NAME:latest .
docker push $DOCKERHUB_USERNAME/$DOCKERHUB_API_IMAGE_NAME:latest
echo "##########(이미지 push 완료)##########"
deploy:
runs-on: ubuntu-latest
needs: build
name: Deploy
steps:
- name: executing remote ssh commands using ssh key
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
key: ${{ secrets.KEY }}
port: ${{ secrets.PORT }}
script: |
cd siperfume-fast-api
sudo docker-compose pull
sudo docker rm -f $(sudo docker ps -a -q)
sudo docker-compose up --force-recreate --remove-orphans -d
sudo docker image prune -f

0 comments on commit a4d9675

Please sign in to comment.