From f36365f53332db2909be9d6450a08ac17ff28ff9 Mon Sep 17 00:00:00 2001 From: JuHyeonPark Date: Fri, 19 Jan 2024 00:09:50 +0900 Subject: [PATCH 1/2] =?UTF-8?q?ci:=20develop=20=EB=B8=8C=EB=9E=9C=EC=B9=98?= =?UTF-8?q?=20=EC=9E=90=EB=8F=99=20=EB=B0=B0=ED=8F=AC=20=EC=8A=A4=ED=81=AC?= =?UTF-8?q?=EB=A6=BD=ED=8A=B8=20=EC=9E=91=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit develop 브랜치 자동 배포 스크립트 작성 --- .github/workflows/cd-develop.yml | 59 ++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/cd-develop.yml diff --git a/.github/workflows/cd-develop.yml b/.github/workflows/cd-develop.yml new file mode 100644 index 00000000..790d6cdd --- /dev/null +++ b/.github/workflows/cd-develop.yml @@ -0,0 +1,59 @@ +name: Java CI with Gradle + +on: + push: + branches: [ develop ] + +permissions: + contents: read + +jobs: + build-develop: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + - name: application.yml + run: | + mkdir -p src/main/resources + touch ./src/main/resources/application.yml + echo "${{ secrets.DEVELOP_APPLICATION_YML }}" > ./src/main/resources/application.yml + cat ./src/main/resources/application.yml + - name: Run chmod to make gradlew executable + run: chmod +x ./gradlew + - name: Build with Gradle + uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25 # v2.6.0 + with: + arguments: build -x test + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: build-file + path: build/libs/*.jar + + deploy: + needs: build-develop + runs-on: ubuntu-latest + steps: + - name: Download artifact + uses: actions/download-artifact@v2 + with: + name: build-file + - name: Setup SSH + uses: webfactory/ssh-agent@v0.5.4 + with: + ssh-private-key: ${{ secrets.DEVELOP_SSH_PRIVATE_KEY }} + - name: Add remote server to known hosts + run: | + mkdir -p ~/.ssh + ssh-keyscan ${{ secrets.DEVELOP_SERVER_IP }} >> ~/.ssh/known_hosts + - name: SCP transfer + run: scp *.jar ${{ secrets.DEVELOP_SERVER_USERNAME }}@${{ secrets.DEVELOP_SERVER_IP }}:~/cicd + - name: Execute remote commands + run: | + ssh -v ${{ secrets.DEVELOP_SERVER_USERNAME }}@${{ secrets.DEVELOP_SERVER_IP }} "sudo fuser -k 80/tcp || true" + ssh -v ${{ secrets.DEVELOP_SERVER_USERNAME }}@${{ secrets.DEVELOP_SERVER_IP }} "sudo nohup /usr/bin/java -jar ~/cicd/*.jar > ~/cicd/nohup.log 2>&1 &" \ No newline at end of file From 640c23a64113c58560396f300d80717b4a8f4acb Mon Sep 17 00:00:00 2001 From: JuHyeonPark Date: Fri, 19 Jan 2024 00:18:35 +0900 Subject: [PATCH 2/2] =?UTF-8?q?build:=20jar=20=EC=9E=90=EB=8F=99=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1=20=EB=B6=88=EA=B0=80=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit jar 자동 생성 불가 설정 --- build.gradle | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.gradle b/build.gradle index 04243689..bbcd119f 100644 --- a/build.gradle +++ b/build.gradle @@ -62,6 +62,10 @@ tasks.named('test') { useJUnitPlatform() } +tasks.named("jar") { + enabled = false +} + def queryDslSrcDir = 'src/main/generated' clean { delete file(queryDslSrcDir)