-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |