From c13f1a24185b1b7696b9380414b75b537982475d Mon Sep 17 00:00:00 2001 From: ByeongIk Choi Date: Tue, 14 Nov 2023 14:03:43 +0900 Subject: [PATCH 1/9] =?UTF-8?q?setup:=20ESLint=20CI=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reviewdog/action-eslint를 활용한 CI를 추가하였습니다. --- .github/workflows/backend-eslint-ci.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/backend-eslint-ci.yml diff --git a/.github/workflows/backend-eslint-ci.yml b/.github/workflows/backend-eslint-ci.yml new file mode 100644 index 0000000..d874d3d --- /dev/null +++ b/.github/workflows/backend-eslint-ci.yml @@ -0,0 +1,17 @@ +name: backend-eslint-ci +on: [pull_request] +jobs: + eslint: + name: runner / eslint + runs-on: ubuntu-latest + permissions: + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-eslint@v1 + with: + eslint_flags: "src/" + filter_mode: file + workdir: "backend" + fail_on_error: true From 1a248ae91ba47fdb9bacf004ec5245a5a60bcfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Tue, 14 Nov 2023 21:05:10 +0900 Subject: [PATCH 2/9] =?UTF-8?q?fix:=20eslint=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EC=A0=81=EC=9A=A9=20=EA=B2=BD=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-eslint-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/backend-eslint-ci.yml b/.github/workflows/backend-eslint-ci.yml index d874d3d..49a11ce 100644 --- a/.github/workflows/backend-eslint-ci.yml +++ b/.github/workflows/backend-eslint-ci.yml @@ -1,5 +1,8 @@ name: backend-eslint-ci -on: [pull_request] +on: + pull_request: + paths: + - backend/** jobs: eslint: name: runner / eslint From a2dfb67fa37c5c13e77301c8341d25a31bae70a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:52:40 +0900 Subject: [PATCH 3/9] =?UTF-8?q?setup:=20Backend=20CD=20=EC=9B=8C=ED=81=AC?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-deploy.yml | 52 ++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/backend-deploy.yml diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml new file mode 100644 index 0000000..77dcf33 --- /dev/null +++ b/.github/workflows/backend-deploy.yml @@ -0,0 +1,52 @@ +name: auto deploy + +on: + push: + branches: + - release + +jobs: + push_to_registry: + name: Push to ncp container registry + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to NCP Container Registry + uses: docker/login-action@v2 + with: + registry: ${{ secrets.NCP_CONTAINER_REGISTRY }} + username: ${{ secrets.NCP_ACCESS_KEY }} + password: ${{ secrets.NCP_SECRET_KEY }} + - name: build and push + uses: docker/build-push-action@v3 + with: + context: . + file: ./cd-test-nest/Dockerfile + push: true + tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server:latest + cache-from: type=registry,ref=${{ secrets.PRODUCTION_CONTAINER_REGISTRY }}/server:latest + cache-to: type=inline + secrets: | + GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }} + + pull_from_registry: + name: Connect server ssh and pull from container registry + needs: push_to_registry + runs-on: ubuntu-latest + steps: + - name: connect ssh + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.SERVER_HOST }} + username: ${{ secrets.SERVER_USERNAME }} + password: ${{ secrets.SERVER_PASSWORD }} + port: ${{ secrets.SERVER_PORT }} + script: | + docker pull ${{ secrets.NCP_CONTAINER_REGISTRY }}/server + docker stop $(docker ps -a -q) + docker rm $(docker ps -a -q) + docker run -d -p 80:3000 --env-file ${{ secrets.ENV_FILE }} ${{ secrets.NCP_CONTAINER_REGISTRY }}/server + docker image prune -f From ab733baa393063d569243bd3d6fbeab5bcbba0a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:56:26 +0900 Subject: [PATCH 4/9] =?UTF-8?q?fix:=20backend=20=EC=9B=8C=ED=81=AC?= =?UTF-8?q?=ED=94=8C=EB=A1=9C=EC=9A=B0=20=EB=8F=84=EC=BB=A4=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml index 77dcf33..5e59897 100644 --- a/.github/workflows/backend-deploy.yml +++ b/.github/workflows/backend-deploy.yml @@ -24,7 +24,7 @@ jobs: uses: docker/build-push-action@v3 with: context: . - file: ./cd-test-nest/Dockerfile + file: ./backend/Dockerfile push: true tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server:latest cache-from: type=registry,ref=${{ secrets.PRODUCTION_CONTAINER_REGISTRY }}/server:latest From ffd53a88bccf71a5e84e9718353c4d197a888a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 14:58:47 +0900 Subject: [PATCH 5/9] =?UTF-8?q?setup:=20backend=20Dockerfile=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 backend/Dockerfile diff --git a/backend/Dockerfile b/backend/Dockerfile new file mode 100644 index 0000000..19be32c --- /dev/null +++ b/backend/Dockerfile @@ -0,0 +1,15 @@ +FROM node:lts-alpine + +WORKDIR /usr/src/app + +COPY ./cd-test-nest/package*.json ./ + +RUN npm install + +COPY ./cd-test-nest/. . + +RUN npm run build + +EXPOSE 3000 + +CMD ["npm", "start"] From 886379a604f1d5e75f28bef41c3854cb46192d28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:23:26 +0900 Subject: [PATCH 6/9] =?UTF-8?q?fix:=20Dockerfile=20=EB=82=B4=EB=B6=80=20?= =?UTF-8?q?=EA=B2=BD=EB=A1=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/Dockerfile b/backend/Dockerfile index 19be32c..4e08f4a 100644 --- a/backend/Dockerfile +++ b/backend/Dockerfile @@ -2,11 +2,11 @@ FROM node:lts-alpine WORKDIR /usr/src/app -COPY ./cd-test-nest/package*.json ./ +COPY ./backend/package*.json ./ RUN npm install -COPY ./cd-test-nest/. . +COPY ./backend/. . RUN npm run build From 85c95f96f903a3deed89cc744d0cb63def12c2a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 15:25:32 +0900 Subject: [PATCH 7/9] =?UTF-8?q?fix:=20name=20=EC=BB=A8=EB=B2=A4=EC=85=98?= =?UTF-8?q?=20=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-eslint-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-eslint-ci.yml b/.github/workflows/backend-eslint-ci.yml index 49a11ce..eb5e4ee 100644 --- a/.github/workflows/backend-eslint-ci.yml +++ b/.github/workflows/backend-eslint-ci.yml @@ -1,4 +1,4 @@ -name: backend-eslint-ci +name: ESLint Check on: pull_request: paths: From fa7541186cf9b33c794b421a3215a81546519367 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 19:15:39 +0900 Subject: [PATCH 8/9] =?UTF-8?q?fix:=20CD=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20name=20=EC=BB=A8=EB=B2=A4=EC=85=98=20?= =?UTF-8?q?=ED=86=B5=EC=9D=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-deploy.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml index 5e59897..5ef86eb 100644 --- a/.github/workflows/backend-deploy.yml +++ b/.github/workflows/backend-deploy.yml @@ -1,9 +1,8 @@ -name: auto deploy - +name: 🍀 Deploy to Naver Cloud Platform on: push: branches: - - release + - release # Only in release branch jobs: push_to_registry: From b5e9583ef56939d508b380df8e9d0e96e55b2eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=86=90=EB=AC=B8=EA=B8=B0?= <39684860+Muungi@users.noreply.github.com> Date: Wed, 15 Nov 2023 20:49:14 +0900 Subject: [PATCH 9/9] =?UTF-8?q?fix:=20CD=20=EC=9B=8C=ED=81=AC=ED=94=8C?= =?UTF-8?q?=EB=A1=9C=EC=9A=B0=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/backend-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend-deploy.yml b/.github/workflows/backend-deploy.yml index 5ef86eb..6e566fb 100644 --- a/.github/workflows/backend-deploy.yml +++ b/.github/workflows/backend-deploy.yml @@ -26,7 +26,7 @@ jobs: file: ./backend/Dockerfile push: true tags: ${{ secrets.NCP_CONTAINER_REGISTRY }}/server:latest - cache-from: type=registry,ref=${{ secrets.PRODUCTION_CONTAINER_REGISTRY }}/server:latest + cache-from: type=registry,ref=${{ secrets.NCP_CONTAINER_REGISTRY }}/server:latest cache-to: type=inline secrets: | GIT_AUTH_TOKEN=${{ secrets.GITHUB_TOKEN }}