From 66cdfe7a4c42c57dad45e33e0193b0052d11a53e Mon Sep 17 00:00:00 2001 From: rlarltj123 Date: Sun, 26 May 2024 23:33:09 +0900 Subject: [PATCH] =?UTF-8?q?chore:=20github=20workflow=EB=A5=BC=20=EC=9E=AC?= =?UTF-8?q?=EC=84=A4=EC=A0=95=ED=95=9C=EB=8B=A4.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build.yml | 8 +++----- .github/workflows/deploy-dev.yml | 16 ++++++---------- .github/workflows/deploy-prod.yml | 18 +++++++----------- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cd094cc..6492e79 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,7 +2,9 @@ name: gradle build on: pull_request: - branches: [ main ] + branches: + - main + - dev # 권한 설정 permissions: write-all @@ -25,10 +27,6 @@ jobs: - name: Set up Environment run: echo "${{ secrets.ENV_PROPERTIES_LOCAL }}" > ./.env - # docker로 Test용 mysql 띄우기 - - name: Create Mysql Docker Container - run: sudo docker run -d -p 3306:3306 --env MYSQL_DATABASE="${{ secrets.TEST_DATABASE }}" --env MYSQL_ROOT_PASSWORD="${{ secrets.TEST_DATASOURCE_PASSWORD }}" mysql:8.0.31 - # 빌드시 캐시 적용 - name: Cache Gradle Packages uses: actions/cache@v3 diff --git a/.github/workflows/deploy-dev.yml b/.github/workflows/deploy-dev.yml index 0626b6e..3b03cc6 100644 --- a/.github/workflows/deploy-dev.yml +++ b/.github/workflows/deploy-dev.yml @@ -30,16 +30,12 @@ jobs: - name: Send env file uses: appleboy/scp-action@master with: - username: ${{ secrets.USERNAME }} - host: ${{ secrets.NCP_HOST }} + username: root + host: ${{ secrets.NCP_DEV_IP }} password: ${{ secrets.NCP_PASSWORD }} source: "./.env" target: "/home/ubuntu" - # 도커 MYSQL 이미지 실행 - - name: Create Mysql Docker Container - run: sudo docker run -d -p 3306:3306 --env MYSQL_DATABASE="${{ secrets.TEST_DATABASE }}" --env MYSQL_ROOT_PASSWORD="${{ secrets.TEST_DATASOURCE_PASSWORD }}" mysql:8.0.31 - # 빌드 - name: Build with Gradle run: ./gradlew clean bootJar @@ -55,8 +51,8 @@ jobs: - name: Send docker-compose.yml uses: appleboy/scp-action@master with: - username: ${{ secrets.USERNAME }} - host: ${{ secrets.NCP_HOST }} + username: root + host: ${{ secrets.NCP_DEV_IP }} password: ${{ secrets.NCP_PASSWORD }} port: 22 source: "./.docker/docker-compose.yml" @@ -66,8 +62,8 @@ jobs: - name: Deploy to Dev uses: appleboy/ssh-action@master with: - username: ${{ secrets.USERNAME }} - host: ${{ secrets.NCP_HOST }} + username: root + host: ${{ secrets.NCP_DEV_IP }} password: ${{ secrets.NCP_PASSWORD }} script: | sudo cp /home/ubuntu/.docker/docker-compose.yml /home/ubuntu diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml index b87946b..64946e8 100644 --- a/.github/workflows/deploy-prod.yml +++ b/.github/workflows/deploy-prod.yml @@ -30,16 +30,12 @@ jobs: - name: Send env file uses: appleboy/scp-action@master with: - username: ${{ secrets.USERNAME }} - host: ${{ secrets.NCP_PROD_HOST }} + username: root + host: ${{ secrets.NCP_PROD_IP }} password: ${{ secrets.NCP_PROD_PASSWORD }} source: "./.env" target: "/home/ubuntu" - # 도커 MYSQL 이미지 실행 - - name: Create Mysql Docker Container - run: sudo docker run -d -p 3306:3306 --env MYSQL_DATABASE="${{ secrets.TEST_DATABASE }}" --env MYSQL_ROOT_PASSWORD="${{ secrets.TEST_DATASOURCE_PASSWORD }}" mysql:8.0.31 - # 빌드 - name: Build with Gradle run: ./gradlew clean bootJar @@ -55,19 +51,19 @@ jobs: - name: Send docker-compose.yml uses: appleboy/scp-action@master with: - username: ${{ secrets.USERNAME }} - host: ${{ secrets.NCP_PROD_HOST }} + username: root + host: ${{ secrets.NCP_PROD_IP }} password: ${{ secrets.NCP_PROD_PASSWORD }} port: 22 source: "./.docker/docker-compose.yml" target: "/home/ubuntu/" # 도커 컴포즈 실행 - - name: Deploy to Dev + - name: Deploy to Prod uses: appleboy/ssh-action@master with: - username: ${{ secrets.USERNAME }} - host: ${{ secrets.NCP_PROD_HOST }} + username: root + host: ${{ secrets.NCP_PROD_IP }} password: ${{ secrets.NCP_PROD_PASSWORD }} script: | sudo cp /home/ubuntu/.docker/docker-compose.yml /home/ubuntu