Skip to content

Api Server Deploy

Api Server Deploy #16

Workflow file for this run

name: Api Server Deploy
on:
push:
branches:
- server-deploy
workflow_dispatch: # 수동 실행 가능
jobs:
CI:
runs-on: ubuntu-latest
environment: server-deploy
steps:
- uses: actions/checkout@v4
name: checkout server-deploy branch
with:
ref: server-deploy
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
# 여기까지는 설정으로 보임
# 로그인
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.SERVER_DOCKER_USERNAME }}
password: ${{ secrets.SERVER_DOCKER_PASSWORD }}
# - name: ls
# working-directory: ./backend
# run: ls -al
- name: docker 이미지 푸시
working-directory: ./backend # 백엔드 폴더에서 실행
run: |
chmod +x ./docker-deploy.sh
./docker-deploy.sh
# - name: docker-compose.yml 파일 도커 환경으로 보내기
# uses: appleboy/scp-action@master
# with:
# host: ${{ secrets.SERVER_AWS_HOST }}
# username: ${{ secrets.SERVER_AWS_USER }}
# port: ${{ secrets.SERVER_AWS_PORT }}
# password: ${{ secrets.SERVER_AWS_KEY }}
# source: "./backend/docker-compose.yml"
# target: "~/"
CD:
runs-on: ubuntu-latest
environment: server-deploy
needs: CI
steps:
- name: ssh 기반 배포
uses: appleboy/ssh-action@master
with:
host: ${{secrets.SERVER_AWS_HOST}}
username: ${{secrets.SERVER_AWS_USER}}
port: ${{secrets.SERVER_AWS_PORT}}
key: ${{secrets.SERVER_AWS_KEY}}
script: |
docker-compose stop
docker pull blaxsior/api-server
docker-compose up -d --build
# -d: 백그라운드 / --build: 실행 전에 빌드부터 수행