From c986cbabcca61891a8759b8e12c719fadbb8c0c1 Mon Sep 17 00:00:00 2001 From: hannkim Date: Tue, 23 Jul 2024 20:50:03 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=9A=20[Release]=20workflow=20=EB=B9=8C?= =?UTF-8?q?=EB=93=9C=EC=99=80=20=EB=B0=B0=ED=8F=AC=20job=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC=20(#643)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 24 +++++++++++++++++++ .../{docker-cd.yml => docker-build.yml} | 22 +---------------- 2 files changed, 25 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/deploy.yml rename .github/workflows/{docker-cd.yml => docker-build.yml} (64%) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..4cdc5085 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,24 @@ + +name: Deploy + +on: + workflow_dispatch: + +jobs: + deploy-to-ec2: + runs-on: ubuntu-latest + + steps: + - name: Deploy to Server + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.EC2_HOST }} + username: ${{ secrets.EC2_USER }} + key: ${{ secrets.SERVER_SSH_KEY }} + envs: GITHUB_SHA + script: | + sudo docker-compose -f ~/docker-compose.yml down && \ + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest && \ + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest && \ + sudo docker-compose -f ~/docker-compose.yml up -d --build + sudo docker image prune -f \ No newline at end of file diff --git a/.github/workflows/docker-cd.yml b/.github/workflows/docker-build.yml similarity index 64% rename from .github/workflows/docker-cd.yml rename to .github/workflows/docker-build.yml index 5c147feb..43ec5c2b 100644 --- a/.github/workflows/docker-cd.yml +++ b/.github/workflows/docker-build.yml @@ -43,24 +43,4 @@ jobs: VITE_API_URL=${{ secrets.VITE_BASE_URL }}/api/v1 VITE_ASSET_URL=${{ secrets.VITE_BASE_URL }} push: true - tags: ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest - - deploy-to-ec2: - runs-on: ubuntu-latest - needs: build-and-push - - steps: - - name: Deploy to Server - uses: appleboy/ssh-action@master - with: - host: ${{ secrets.EC2_HOST }} - username: ${{ secrets.EC2_USER }} - key: ${{ secrets.SERVER_SSH_KEY }} - envs: GITHUB_SHA - script: | - sudo docker ps - sudo docker compose -f ~/docker-compose.yml down && \ - sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostserver:latest && \ - sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest && \ - sudo docker compose -f ~/docker-compose.yml up -d - sudo docker image prune -f + tags: ${{ secrets.DOCKER_USERNAME }}/ghostclient:latest \ No newline at end of file