From 8681257912b1c01456b2050b9ef2f7f57f34aa1f Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Sun, 2 Mar 2025 14:29:26 +0900 Subject: [PATCH 1/2] =?UTF-8?q?chore:=20prod=20cd=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd-prod.yml | 72 +++++++++++++++++++++++++++++++++++ 1 file changed, 72 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 00000000..c5c5e509 --- /dev/null +++ b/.github/workflows/cd-prod.yml @@ -0,0 +1,72 @@ +name: cd prod + +on: + pull_request: + branches: [ "main" ] + types: [closed] + +jobs: + deploy: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: read + + steps: + - name: Checkout sources + uses: actions/checkout@v4 + with: + token: ${{ secrets.SUBMODULE_TOKEN }} + submodules: true + + - name: Setup JDK 21 + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: '21' + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v4 + + - name: Cache Gradle + id: cache-gradle + uses: actions/cache@v4 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Create directory resources + run: mkdir -p ./src/test/resources + + - name: Copy application.yml + run: | + cp ./server-config/*.yml ./src/main/resources/ + cp ./server-config/application-test.yml ./src/test/resources/application.yml + + - name: Build with Gradle + run: ./gradlew bootJar + + - name: Copy jar file + run: mv ./build/libs/*SNAPSHOT.jar ./photopic-prod.jar + + - name: (SCP) transfer build file + uses: appleboy/scp-action@v0.1.7 + with: + host: ${{ secrets.AWS_EC2_URL_PROD }} + username: ${{ secrets.AWS_EC2_USER }} + key: ${{ secrets.AWS_EC2_KEY }} + source: photopic-prod.jar + target: /home/${{ secrets.AWS_EC2_USER }} + + - name: (SSH) connect EC2 + uses: appleboy/ssh-action@v1.0.3 + with: + host: ${{ secrets.AWS_EC2_URL_PROD }} + username: ${{ secrets.AWS_EC2_USER }} + key: ${{ secrets.AWS_EC2_KEY }} + script_stop: true + script: | + sudo fuser -k -n tcp 8080 || true + nohup java -jar -Dspring.profiles.active=prod photopic-prod.jar > ./output.log 2>&1 & From b3aad534f87fe9e500aaef5fe7e4da404dca0309 Mon Sep 17 00:00:00 2001 From: wlsh44 Date: Sun, 2 Mar 2025 14:29:56 +0900 Subject: [PATCH 2/2] =?UTF-8?q?chore:=20prod=20=EC=84=A4=EC=A0=95=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=20=EA=B0=B1=EC=8B=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server-config b/server-config index b6d9f9e1..e30e07df 160000 --- a/server-config +++ b/server-config @@ -1 +1 @@ -Subproject commit b6d9f9e189eaa4093df0f6089fc30d23fd5c81ac +Subproject commit e30e07dfdf425a36d06189d1699d5edfb887a383