From fbda9800306c38aadd3cbcdc09a8bc9b341e0cc4 Mon Sep 17 00:00:00 2001 From: jungeun Date: Mon, 23 Sep 2024 11:26:17 +0900 Subject: [PATCH] =?UTF-8?q?fix=20:=20=EB=8F=84=EC=BB=A4=20=EC=9D=B4?= =?UTF-8?q?=EB=AF=B8=EC=A7=80=20=EC=83=88=EB=A1=9C=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=ED=95=98=EA=B3=A0=20=EB=B9=8C=EB=93=9C=ED=95=98=EB=8F=84?= =?UTF-8?q?=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/nodejs-ci.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/nodejs-ci.yml b/.github/workflows/nodejs-ci.yml index d81b8ad..058e6d8 100644 --- a/.github/workflows/nodejs-ci.yml +++ b/.github/workflows/nodejs-ci.yml @@ -26,8 +26,8 @@ jobs: - name: Install dependencies run: npm install - # - name: Build project - # run: npm run build + - name: Build project + run: npm run build # 프로젝트 빌드 명령 추가 docker-build: runs-on: ubuntu-latest @@ -54,7 +54,7 @@ jobs: runs-on: ubuntu-latest needs: docker-build steps: - - name: deploy + - name: Deploy to server uses: appleboy/ssh-action@master with: username: ubuntu @@ -62,14 +62,19 @@ jobs: key: ${{ secrets.PRIVATE_KEY }} port: ${{ secrets.WAS_PORT }} script: | + # 기존 컨테이너가 실행 중이면 종료하고 삭제 CONTAINER_ID=$(sudo docker ps -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}) if [ ! -z "$CONTAINER_ID" ]; then sudo docker stop $CONTAINER_ID sudo docker rm $CONTAINER_ID fi - sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }} - sudo docker run -d -p 9000:9000 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }} + # 최신 이미지를 가져와서 실행 + sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}:latest + sudo docker run -d -p 9000:9000 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}:latest + + # 로그 확인 sudo docker logs $(sudo docker ps -q --filter ancestor=${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}) + # 사용하지 않는 도커 이미지 제거 sudo docker image prune -f