From d0ef7eec56570198453fe910bcae9d43e04a9be7 Mon Sep 17 00:00:00 2001 From: hyoseong-Choi Date: Mon, 3 Feb 2025 12:12:49 +0900 Subject: [PATCH 1/2] =?UTF-8?q?:construction=5Fworker:=20[cicd]=20:=20?= =?UTF-8?q?=EB=8F=84=EC=BB=A4=ED=8C=8C=EC=9D=BC=20dist=20copy=20=EA=B2=BD?= =?UTF-8?q?=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/{cicd.yml => CD.yml} | 118 ++++++++++++------------- .github/workflows/CI.yml | 33 +++++++ 2 files changed, 90 insertions(+), 61 deletions(-) rename .github/workflows/{cicd.yml => CD.yml} (86%) create mode 100644 .github/workflows/CI.yml diff --git a/.github/workflows/cicd.yml b/.github/workflows/CD.yml similarity index 86% rename from .github/workflows/cicd.yml rename to .github/workflows/CD.yml index 88129bed..69d22210 100644 --- a/.github/workflows/cicd.yml +++ b/.github/workflows/CD.yml @@ -1,61 +1,57 @@ -# github repository actions 페이지에 나타날 이름 -name: CI/CD for front using github actions - -# event trigger -# develop 브랜치에 pull_request가 닫히거나 푸시했을때 실행 -on: - pull_request: - types: [closed] - branches: [ "develop" ] - push: - branches: [ "develop" ] - - -permissions: - contents: read - -jobs: - front-cicd: - runs-on: ubuntu-latest - steps: - # 저장소 코드를 체크아웃합니다. (PR 올린 코드를 가져오는 행위) - - uses: actions/checkout@v4 - - # Node.js 환경 설정 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: 22 # 지정된 Node.js 버전 사용 - cache: npm # setup-node 의 캐시 기능을 사용함 - cache-dependency-path: package-lock.json # 캐시 기능을 사용할 때 캐시의 기준이 될 파일을 지정 - - - name: Install Dependencies - run: npm install - - - name: Build with npm - run: npm run build || exit 0 # exit 0를 추가하여 경고성 오류 무시 - - - name: Create nginx.conf - run: touch ./nginx.conf - - run: echo "${{ secrets.NGINX_CONF }}" > ./nginx.conf - - ## docker build & push to production - - name: Docker build & push - run: | - docker login clap.kr-central-2.kcr.dev -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} - docker build -t ${{ secrets.DOCKER_FRONT_REPO }} . - docker push ${{ secrets.DOCKER_FRONT_REPO }} - - ## deploy - - name: Deploy - uses: appleboy/ssh-action@master - id: deploy - with: - host: ${{ secrets.FRONT_HOST }} - username: ${{ secrets.FRONT_HOST_USERNAME }} - key: ${{ secrets.FRONT_HOST_KEY }} - port: ${{ secrets.FRONT_HOST_PORT }} - script: | - docker rm -f taskflow-front - docker image rm ${{ secrets.DOCKER_FRONT_REPO }} -f - docker run --name taskflow-front -d -p 80:80 --restart on-failure ${{ secrets.DOCKER_FRONT_REPO }} +# github repository actions 페이지에 나타날 이름 +name: CD for front using github actions + +# event trigger +# develop 브랜치에 pull_request가 닫히거나 푸시했을때 실행 +on: + push: + branches: [ "CLAP-234" ] + +permissions: + contents: read + +jobs: + front-cicd: + runs-on: ubuntu-latest + steps: + # 저장소 코드를 체크아웃합니다. (PR 올린 코드를 가져오는 행위) + - uses: actions/checkout@v4 + + # Node.js 환경 설정 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 # 지정된 Node.js 버전 사용 + cache: npm # setup-node 의 캐시 기능을 사용함 + cache-dependency-path: package-lock.json # 캐시 기능을 사용할 때 캐시의 기준이 될 파일을 지정 + + - name: Install Dependencies + run: npm install + + - name: Build with npm + run: npm run build-only + + - name: Create nginx.conf + run: touch ./nginx.conf + - run: echo "${{ secrets.NGINX_CONF }}" > ./nginx.conf + + ## docker build & push to production + - name: Docker build & push + run: | + docker login clap.kr-central-2.kcr.dev -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -t ${{ secrets.DOCKER_FRONT_REPO }} . + docker push ${{ secrets.DOCKER_FRONT_REPO }} + + ## deploy + - name: Deploy + uses: appleboy/ssh-action@master + id: deploy + with: + host: ${{ secrets.FRONT_HOST }} + username: ${{ secrets.FRONT_HOST_USERNAME }} + key: ${{ secrets.FRONT_HOST_KEY }} + port: ${{ secrets.FRONT_HOST_PORT }} + script: | + docker rm -f taskflow-front + docker image rm ${{ secrets.DOCKER_FRONT_REPO }} -f + docker run --name taskflow-front -d -p 80:80 --restart on-failure ${{ secrets.DOCKER_FRONT_REPO }} diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 00000000..1d1b61df --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,33 @@ +# github repository actions 페이지에 나타날 이름 +name: CI for front using github actions + +# event trigger +# develop 브랜치에 pull_request가 닫히거나 푸시했을때 실행 +on: + pull_request: + types: [ opened, synchronize ] + branches: [ "CLAP-234" ] + +permissions: + contents: read + +jobs: + front-cicd: + runs-on: ubuntu-latest + steps: + # 저장소 코드를 체크아웃합니다. (PR 올린 코드를 가져오는 행위) + - uses: actions/checkout@v4 + + # Node.js 환경 설정 + - name: Use Node.js + uses: actions/setup-node@v4 + with: + node-version: 22 # 지정된 Node.js 버전 사용 + cache: npm # setup-node 의 캐시 기능을 사용함 + cache-dependency-path: package-lock.json # 캐시 기능을 사용할 때 캐시의 기준이 될 파일을 지정 + + - name: Install Dependencies + run: npm install + + - name: Build with npm + run: npm run build-only \ No newline at end of file From 32a52df0d9ac7c5dac35f42eefb6d3b9caae9cfa Mon Sep 17 00:00:00 2001 From: hyoseong-Choi Date: Mon, 3 Feb 2025 12:17:04 +0900 Subject: [PATCH 2/2] =?UTF-8?q?:construction=5Fworker:=20[cicd]=20:=20CI/C?= =?UTF-8?q?D=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/CD.yml | 2 +- .github/workflows/CI.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/CD.yml b/.github/workflows/CD.yml index 69d22210..619d7d6f 100644 --- a/.github/workflows/CD.yml +++ b/.github/workflows/CD.yml @@ -5,7 +5,7 @@ name: CD for front using github actions # develop 브랜치에 pull_request가 닫히거나 푸시했을때 실행 on: push: - branches: [ "CLAP-234" ] + branches: [ "develop" ] permissions: contents: read diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 1d1b61df..d68ac831 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -6,7 +6,7 @@ name: CI for front using github actions on: pull_request: types: [ opened, synchronize ] - branches: [ "CLAP-234" ] + branches: [ "develop" ] permissions: contents: read