From b0ed8cee7b3d83f22ec31747ea5b285f933fb251 Mon Sep 17 00:00:00 2001 From: minjun Date: Wed, 25 Sep 2024 10:18:02 +0900 Subject: [PATCH] =?UTF-8?q?feat=20:=20github=20action=20=EB=B0=B0=ED=8F=AC?= =?UTF-8?q?=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=B6=94=EA=B0=80=20?= =?UTF-8?q?(#118)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-prod.yml | 39 +++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 .github/workflows/cd-prod.yml diff --git a/.github/workflows/cd-prod.yml b/.github/workflows/cd-prod.yml new file mode 100644 index 0000000..70633b4 --- /dev/null +++ b/.github/workflows/cd-prod.yml @@ -0,0 +1,39 @@ +name: Deploy - prod + +on: + push: + branches: + - main + +jobs: + build: + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [16.16.0] + + steps: + - uses: actions/checkout@v2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v1 + with: + node-version: ${{ matrix.node-version }} + + - name: docker build and push + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t ${{ secrets.DOCKER_REPO }}/clubber-front . + docker push ${{ secrets.DOCKER_REPO }}/clubber-front + + - name: executing remote ssh commands using password + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SSH_HOST_PROD }} + username: ${{ secrets.SSH_USERNAME }} + key: ${{ secrets.SSH_KEY_PROD }} + script: | + sudo docker rm -f $(docker ps -qa) + sudo docker pull ${{ secrets.DOCKER_REPO }}/clubber-front + docker-compose up -d + docker image prune -f