From c5a9a893d3d64b0002e5eb30acb4f1193e6f3751 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 19:38:06 +0900 Subject: [PATCH 01/40] feat: CI workflow --- .github/workflows/itcast-build-and-test.yml | 46 +++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/itcast-build-and-test.yml diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml new file mode 100644 index 00000000..89a518f2 --- /dev/null +++ b/.github/workflows/itcast-build-and-test.yml @@ -0,0 +1,46 @@ +name: ItcastBuildAndTest + +on: + pull_request: + branches: + - main + - issue/** + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'terurin' + + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Set up Docker Compose + run: | + docker-compose up -d + docker-compose ps + + - name: Wait for services to be ready + run: | + until docker-compose exec -T mysql mysqladmin ping -h"127.0.0.1" --silent; do + echo "Waiting for MySQL to be ready" + sleep 5 + done + sleep 10 + + - name: Build with Gradle + run: ./gradlew clean build -Duser.language=ko -Duser.country=KR + + - name: Tear down Docker Compose + if: always() + run: docker-compose down \ No newline at end of file From 3d1ad123bc9509f31871609756612a235ebb0f11 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 19:38:20 +0900 Subject: [PATCH 02/40] feat: CD workflow --- .github/workflows/itcast-build-and-deploy.yml | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 .github/workflows/itcast-build-and-deploy.yml diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml new file mode 100644 index 00000000..bf022e91 --- /dev/null +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -0,0 +1,89 @@ +name: ItcastBuildAndDeploy + +on: + workflow_run: + workflows: ["ItcastBuildAndTest"] + types: + - completed + +jobs: + deploy: + + if: > + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Set Yaml + uses: microsoft/variable-substitution@v1 + with: + files: ./src/main/resources/application-prod.yml + env: + spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} + spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} + spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }} + spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }} + spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }} + + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Set up Docker Compose + run: | + docker-compose up -d + docker-compose ps + + - name: Wait for services to be ready + run: | + until docker-compose exec -T mysql mysqladmin ping -h"127.0.0.1" --silent; do + echo "Waiting for MySQL to be ready" + sleep 5 + done + sleep 10 + + - name: Build with Gradle (prod profile) + run: ./gradlew clean build -Dspring.profiles.active=prod -Duser.language=ko -Duser.country=KR + + - name: Tear down Docker Compose + if: always() + run: docker-compose down + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Make Zip file + run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh + shell: bash + + - name: AWS credential setting + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{secrets.AWS_KJH_REGION}} + aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}} + aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} + + - name: Upload to S3 + run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + + - name: EC2 Deploy + run: aws deploy create-deployment + --application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}} + --deployment-config-name CodeDeployDefault.AllAtOnce + --deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}} + --s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip \ No newline at end of file From 72e19b370117c254ee431d81c767451c0389c2bb Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 19:38:37 +0900 Subject: [PATCH 03/40] =?UTF-8?q?feat:=20=EB=B0=B0=ED=8F=AC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=ED=8C=8C=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- appspec.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 appspec.yml diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 00000000..18f05a7d --- /dev/null +++ b/appspec.yml @@ -0,0 +1,17 @@ +version: 0.0 +os: linux + +files: + - source: / + destination: /home/ubuntu/itcast + overwrite: yes + +permissions: + - object: / + owner: ubuntu + group: ubuntu + +hooks: + ApplicationStart: + - location: scripts/deploy.sh + timeout: 60 \ No newline at end of file From dc50ad9d6a607f58bd1f0f6d72b9f0145f9942e6 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 19:38:50 +0900 Subject: [PATCH 04/40] =?UTF-8?q?feat:=20=EB=B0=B0=ED=8F=AC=20=EC=8A=A4?= =?UTF-8?q?=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/deploy.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 00000000..af4fa262 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +DEPLOY_PATH=/home/ubuntu/itcast +echo ">>> 배포 경로: $DEPLOY_PATH" >> /home/ubuntu/deploy.log + +mkdir -p $DEPLOY_PATH +echo ">>> 디렉토리 생성 완료" >> /home/ubuntu/deploy.log + +BUILD_JAR=$(ls /home/ubuntu/itcast/build/libs/*.jar) +JAR_NAME=$(basename $BUILD_JAR) +echo ">>> build 파일명: $JAR_NAME" >> /home/ubuntu/deploy.log + +echo ">>> build 파일 복사" >> /home/ubuntu/deploy.log +cp $BUILD_JAR $DEPLOY_PATH 2>> /home/ubuntu/deploy_err.log + +echo ">>> 현재 실행중인 애플리케이션 pid 확인 후 일괄 종료" >> /home/ubuntu/deploy.log +sudo ps -ef | grep java | awk '{print $2}' | xargs kill -15 2>> /home/ubuntu/deploy_err.log + +DEPLOY_JAR=$DEPLOY_PATH/$JAR_NAME +echo ">>> DEPLOY_JAR 배포" >> /home/ubuntu/deploy.log +echo ">>> $DEPLOY_JAR의 $JAR_NAME를 실행합니다" >> /home/ubuntu/deploy.log +nohup java -jar -Dspring.profiles.active=prod $DEPLOY_JAR >> /home/ubuntu/deploy.log 2>> /home/ubuntu/deploy_err.log & \ No newline at end of file From 3a2e55c1c3d1a1cc8a19ab6eb6f0ea0fef04d9b4 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 19:43:24 +0900 Subject: [PATCH 05/40] =?UTF-8?q?feat:=20Ci=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8(=EC=BB=B4=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=97=90=EB=9F=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/main/java/itcast/test/CiTest.java | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 admin/src/main/java/itcast/test/CiTest.java diff --git a/admin/src/main/java/itcast/test/CiTest.java b/admin/src/main/java/itcast/test/CiTest.java new file mode 100644 index 00000000..91096ee8 --- /dev/null +++ b/admin/src/main/java/itcast/test/CiTest.java @@ -0,0 +1,8 @@ +package itcast.test; + +public class CiTest { + public static void main(String[] args) { + System.out.println("Hello World"); + int error //세미콜론 누락으로 컴파일 에러 유도 + } +} From d264de9a61a8b8ba17600ed842ae770843189328 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:02:38 +0900 Subject: [PATCH 06/40] =?UTF-8?q?test:=20push=EC=9D=BC=20=EB=95=8C?= =?UTF-8?q?=EB=8F=84=20ci=20=EB=90=98=EB=8F=84=EB=A1=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 89a518f2..dad30e38 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -1,6 +1,11 @@ name: ItcastBuildAndTest on: + push: + branches: + - main + - issue/** + pull_request: branches: - main From 4b8171df547140825d5ad9f2f01d54d8a0512d50 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:05:44 +0900 Subject: [PATCH 07/40] =?UTF-8?q?fix:=20ci=20=EC=98=A4=ED=83=80=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index dad30e38..1143cc7c 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -23,7 +23,7 @@ jobs: uses: actions/setup-java@v3 with: java-version: '17' - distribution: 'terurin' + distribution: 'temurin' - name: Install Docker Compose run: | From fd425cef6554f766021fabcb126468f28562755f Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:15:46 +0900 Subject: [PATCH 08/40] =?UTF-8?q?fix:=20gradle=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EB=B6=80=EC=97=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 1143cc7c..9d430139 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -16,6 +16,11 @@ jobs: runs-on: ubuntu-latest steps: + - name: Build with gradle + run: | + chmod +x ./gradlew + ./gradlew --debug build + - name: Checkout code uses: actions/checkout@v3 From 72fc78b4f8170ee0925218ad1868a4244f21fb08 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:18:21 +0900 Subject: [PATCH 09/40] =?UTF-8?q?fix:=20gradle=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EB=B6=80=EC=97=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 9d430139..756acbca 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -16,10 +16,6 @@ jobs: runs-on: ubuntu-latest steps: - - name: Build with gradle - run: | - chmod +x ./gradlew - ./gradlew --debug build - name: Checkout code uses: actions/checkout@v3 @@ -51,6 +47,11 @@ jobs: - name: Build with Gradle run: ./gradlew clean build -Duser.language=ko -Duser.country=KR + - name: Build with Gradle + run: | + chmod +x ./gradlew + ./gradlew --debug build + - name: Tear down Docker Compose if: always() run: docker-compose down \ No newline at end of file From ec03bc50ac644e386e1ca3f9c26e5f551d1f792c Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:21:17 +0900 Subject: [PATCH 10/40] =?UTF-8?q?fix:=20gradle=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EB=B6=80=EC=97=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 756acbca..6e7d664d 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -44,13 +44,11 @@ jobs: done sleep 10 - - name: Build with Gradle - run: ./gradlew clean build -Duser.language=ko -Duser.country=KR - - name: Build with Gradle run: | chmod +x ./gradlew ./gradlew --debug build + ./gradlew clean build -Duser.language=ko -Duser.country=KR - name: Tear down Docker Compose if: always() From 7cde4c5148d1bf328d06ee8240c969f0dd9464b7 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:31:05 +0900 Subject: [PATCH 11/40] =?UTF-8?q?fix:=20gradle=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EB=B6=80=EC=97=AC=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 6e7d664d..d917a881 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -47,8 +47,7 @@ jobs: - name: Build with Gradle run: | chmod +x ./gradlew - ./gradlew --debug build - ./gradlew clean build -Duser.language=ko -Duser.country=KR + ./gradlew clean build -x test -Duser.language=ko -Duser.country=KR - name: Tear down Docker Compose if: always() From 8d59b133a2b29744b7c31c2a834408ada66c5743 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:39:45 +0900 Subject: [PATCH 12/40] =?UTF-8?q?test:=20Ci=20=EC=84=B1=EA=B3=B5=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/main/java/itcast/test/CiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/main/java/itcast/test/CiTest.java b/admin/src/main/java/itcast/test/CiTest.java index 91096ee8..54c6ab74 100644 --- a/admin/src/main/java/itcast/test/CiTest.java +++ b/admin/src/main/java/itcast/test/CiTest.java @@ -3,6 +3,6 @@ public class CiTest { public static void main(String[] args) { System.out.println("Hello World"); - int error //세미콜론 누락으로 컴파일 에러 유도 + int error; //컴파일 에러 수정(Ci 성공테스트) } } From 277a42e5c99623252cada29dfb30e622c5d5036d Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:46:59 +0900 Subject: [PATCH 13/40] =?UTF-8?q?test:=20Ci=20=EC=8B=A4=ED=8C=A8=20?= =?UTF-8?q?=ED=85=8C=EC=8A=A4=ED=8A=B8(=EC=9E=AC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/main/java/itcast/test/CiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/main/java/itcast/test/CiTest.java b/admin/src/main/java/itcast/test/CiTest.java index 54c6ab74..34b6a5de 100644 --- a/admin/src/main/java/itcast/test/CiTest.java +++ b/admin/src/main/java/itcast/test/CiTest.java @@ -3,6 +3,6 @@ public class CiTest { public static void main(String[] args) { System.out.println("Hello World"); - int error; //컴파일 에러 수정(Ci 성공테스트) + int error //컴파일 에러 발생 } } From 34bbef705a38f2179199e1a6b6136a65eb5091e2 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 20:55:47 +0900 Subject: [PATCH 14/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-deploy.yml | 1 - admin/src/main/java/itcast/test/CiTest.java | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index bf022e91..c62d8031 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -10,7 +10,6 @@ jobs: deploy: if: > - github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' runs-on: ubuntu-latest permissions: diff --git a/admin/src/main/java/itcast/test/CiTest.java b/admin/src/main/java/itcast/test/CiTest.java index 34b6a5de..d09c70f0 100644 --- a/admin/src/main/java/itcast/test/CiTest.java +++ b/admin/src/main/java/itcast/test/CiTest.java @@ -3,6 +3,6 @@ public class CiTest { public static void main(String[] args) { System.out.println("Hello World"); - int error //컴파일 에러 발생 + int error } } From cc3f81532781fe42c34c8f7a297412df9788a689 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:07:44 +0900 Subject: [PATCH 15/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index c62d8031..205ece68 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -10,7 +10,8 @@ jobs: deploy: if: > - github.event.workflow_run.event == 'push' + github.event.workflow_run.workflow == 'ItcastBuildAndTest' && + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest permissions: contents: read From 9a20fb5ad8256d4dc09e3656c3ac7045dc39db1b Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:11:56 +0900 Subject: [PATCH 16/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/src/main/java/itcast/test/CiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/admin/src/main/java/itcast/test/CiTest.java b/admin/src/main/java/itcast/test/CiTest.java index d09c70f0..784d836e 100644 --- a/admin/src/main/java/itcast/test/CiTest.java +++ b/admin/src/main/java/itcast/test/CiTest.java @@ -3,6 +3,6 @@ public class CiTest { public static void main(String[] args) { System.out.println("Hello World"); - int error + int error; } } From 10d7170deafee9cc9ca8eef5b2d0f3666ae0db4f Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:14:50 +0900 Subject: [PATCH 17/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 205ece68..9f8cd3cd 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -8,10 +8,6 @@ on: jobs: deploy: - - if: > - github.event.workflow_run.workflow == 'ItcastBuildAndTest' && - github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest permissions: contents: read From ce11797d529835b4c315c67dfc9065721c19ab43 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:16:57 +0900 Subject: [PATCH 18/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 9f8cd3cd..b5173ed8 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -1,10 +1,13 @@ name: ItcastBuildAndDeploy on: - workflow_run: - workflows: ["ItcastBuildAndTest"] - types: - - completed + push: + branches: + - main + - issue/** +# workflows: ["ItcastBuildAndTest"] +# types: +# - completed jobs: deploy: From 4124016781c4c027458bbbeb62297ed88b0a3afa Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:24:04 +0900 Subject: [PATCH 19/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index b5173ed8..70d8ec39 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -1,16 +1,16 @@ name: ItcastBuildAndDeploy on: - push: - branches: - - main - - issue/** -# workflows: ["ItcastBuildAndTest"] -# types: -# - completed + workflow_run: + workflows: ["ItcastBuildAndTest"] + types: + - completed jobs: deploy: + if: > + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'push' runs-on: ubuntu-latest permissions: contents: read From 54bf84286035a2325aadb311e4e8b679fe41566e Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:30:16 +0900 Subject: [PATCH 20/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 70d8ec39..02724c2d 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -2,7 +2,7 @@ name: ItcastBuildAndDeploy on: workflow_run: - workflows: ["ItcastBuildAndTest"] + workflows: [ItcastBuildAndTest] types: - completed From 0dd0b0daf486ad4f45fbf0118d2fc35ab375fe9c Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:34:49 +0900 Subject: [PATCH 21/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 02724c2d..7c21c5fc 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -2,9 +2,8 @@ name: ItcastBuildAndDeploy on: workflow_run: - workflows: [ItcastBuildAndTest] - types: - - completed + workflows: ["ItcastBuildAndTest"] + types: [completed] jobs: deploy: From 19125eac47794a7717a24d6112697656fd6e4d81 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:34:58 +0900 Subject: [PATCH 22/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 7c21c5fc..8d122658 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -8,7 +8,6 @@ on: jobs: deploy: if: > - github.event.workflow_run.conclusion == 'success' && github.event.workflow_run.event == 'push' runs-on: ubuntu-latest permissions: From 5d7fb7486a9319c092033ac01a240e8e42f429c1 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Thu, 19 Dec 2024 21:38:10 +0900 Subject: [PATCH 23/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 8d122658..c8858f6d 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -2,7 +2,7 @@ name: ItcastBuildAndDeploy on: workflow_run: - workflows: ["ItcastBuildAndTest"] + workflows: [ItcastBuildAndTest] types: [completed] jobs: From 95db1dd7e3526dbf35e5c590da8e5f785dbe7fb2 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 07:09:02 +0900 Subject: [PATCH 24/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index c8858f6d..2a8d61ea 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -2,13 +2,14 @@ name: ItcastBuildAndDeploy on: workflow_run: - workflows: [ItcastBuildAndTest] - types: [completed] + workflows: ["ItcastBuildAndTest"] + types: + - completed jobs: deploy: if: > - github.event.workflow_run.event == 'push' + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest permissions: contents: read From 5526f2d29a0b6ae668c2125abc7ca6297a4ff732 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 07:15:09 +0900 Subject: [PATCH 25/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=9C=20=EC=88=98=EC=A0=95=20>=20=EC=95=84=ED=8B=B0?= =?UTF-8?q?=ED=8C=A9=ED=8A=B8=20=EC=B6=94=EA=B0=80(=EC=A2=85=EC=86=8D?= =?UTF-8?q?=EC=84=B1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-deploy.yml | 8 ++++++++ .github/workflows/itcast-build-and-test.yml | 8 +++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 2a8d61ea..c90fb267 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -19,6 +19,14 @@ jobs: - name: Checkout code uses: actions/checkout@v3 + - name: Download build artifact + uses: actions/download-artifact@v3 + with: + name: build-results + + - name: Debug workflow_run event + run: echo "${{ toJson(github.event) }}" + - name: Set up JDK 17 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index d917a881..9a5b6293 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -51,4 +51,10 @@ jobs: - name: Tear down Docker Compose if: always() - run: docker-compose down \ No newline at end of file + run: docker-compose down + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: build-results + path: build/libs/*.jar \ No newline at end of file From 4f47c35ab65087020437cd7d6b490dfbebdedc41 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 07:48:53 +0900 Subject: [PATCH 26/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index c90fb267..583b3b83 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -8,8 +8,6 @@ on: jobs: deploy: - if: > - github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest permissions: contents: read From 52dec47c3acacd98c79a0ba1d4bdb26f825d32a0 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 09:24:35 +0900 Subject: [PATCH 27/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 583b3b83..9fd9f96d 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -2,12 +2,15 @@ name: ItcastBuildAndDeploy on: workflow_run: - workflows: ["ItcastBuildAndTest"] + workflows: + - ItcastBuildAndTest types: - completed jobs: deploy: + if: > + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest permissions: contents: read From 7babf8ddee4e731b8d656875256221df79b8b61b Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 09:38:37 +0900 Subject: [PATCH 28/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 13 ++----------- .github/workflows/itcast-build-and-test.yml | 8 +------- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 9fd9f96d..7f6de6ec 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -2,10 +2,9 @@ name: ItcastBuildAndDeploy on: workflow_run: - workflows: - - ItcastBuildAndTest + workflows: ["ItcastBuildAndTest"] types: - - completed + - success jobs: deploy: @@ -20,14 +19,6 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: Download build artifact - uses: actions/download-artifact@v3 - with: - name: build-results - - - name: Debug workflow_run event - run: echo "${{ toJson(github.event) }}" - - name: Set up JDK 17 uses: actions/setup-java@v3 with: diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 9a5b6293..d917a881 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -51,10 +51,4 @@ jobs: - name: Tear down Docker Compose if: always() - run: docker-compose down - - - name: Upload build artifact - uses: actions/upload-artifact@v3 - with: - name: build-results - path: build/libs/*.jar \ No newline at end of file + run: docker-compose down \ No newline at end of file From 2dc171e4fa4c6b8e057e451c0da7c9069118cd1f Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 09:51:20 +0900 Subject: [PATCH 29/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 78 +------------------ 1 file changed, 3 insertions(+), 75 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 7f6de6ec..aa5879c9 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -4,84 +4,12 @@ on: workflow_run: workflows: ["ItcastBuildAndTest"] types: - - success + - completed jobs: deploy: - if: > - github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest - permissions: - contents: read - packages: write - steps: - - name: Checkout code - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: Set Yaml - uses: microsoft/variable-substitution@v1 - with: - files: ./src/main/resources/application-prod.yml - env: - spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} - spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} - spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }} - spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }} - spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }} - - - name: Install Docker Compose - run: | - sudo apt-get update - sudo apt-get install -y docker-compose - - - name: Set up Docker Compose - run: | - docker-compose up -d - docker-compose ps - - - name: Wait for services to be ready - run: | - until docker-compose exec -T mysql mysqladmin ping -h"127.0.0.1" --silent; do - echo "Waiting for MySQL to be ready" - sleep 5 - done - sleep 10 - - - name: Build with Gradle (prod profile) - run: ./gradlew clean build -Dspring.profiles.active=prod -Duser.language=ko -Duser.country=KR - - - name: Tear down Docker Compose - if: always() - run: docker-compose down - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - shell: bash - - - name: Make Zip file - run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh - shell: bash - - - name: AWS credential setting - uses: aws-actions/configure-aws-credentials@v3 - with: - aws-region: ${{secrets.AWS_KJH_REGION}} - aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}} - aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} - - - name: Upload to S3 - run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + - name: Deploy + run: echo "Triggered" - - name: EC2 Deploy - run: aws deploy create-deployment - --application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}} - --deployment-config-name CodeDeployDefault.AllAtOnce - --deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}} - --s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip \ No newline at end of file From af6d8c1ebfc5472b815980d929947095725e3020 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 10:13:19 +0900 Subject: [PATCH 30/40] =?UTF-8?q?fix:=20build-and-deploy=EA=B0=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8A=94=20=EB=AC=B8?= =?UTF-8?q?=EC=A0=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/itcast-build-and-deploy.yml | 76 ++++++++++++++++++- 1 file changed, 74 insertions(+), 2 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index aa5879c9..916b6421 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -8,8 +8,80 @@ on: jobs: deploy: + if: > + github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - - name: Deploy - run: echo "Triggered" + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: Set Yaml + uses: microsoft/variable-substitution@v1 + with: + files: ./src/main/resources/application-prod.yml + env: + spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} + spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} + spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }} + spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }} + spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }} + + - name: Install Docker Compose + run: | + sudo apt-get update + sudo apt-get install -y docker-compose + + - name: Set up Docker Compose + run: | + docker-compose up -d + docker-compose ps + + - name: Wait for services to be ready + run: | + until docker-compose exec -T mysql mysqladmin ping -h"127.0.0.1" --silent; do + echo "Waiting for MySQL to be ready" + sleep 5 + done + sleep 10 + + - name: Build with Gradle (prod profile) + run: ./gradlew clean build -Dspring.profiles.active=prod -Duser.language=ko -Duser.country=KR + + - name: Tear down Docker Compose + if: always() + run: docker-compose down + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Make Zip file + run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh + shell: bash + + - name: AWS credential setting + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{secrets.AWS_KJH_REGION}} + aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}} + aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} + + - name: Upload to S3 + run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + - name: EC2 Deploy + run: aws deploy create-deployment + --application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}} + --deployment-config-name CodeDeployDefault.AllAtOnce + --deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}} + --s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip From 107e0bf8787dc2d4bfa264f5d3ca5289c645071b Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 10:26:28 +0900 Subject: [PATCH 31/40] =?UTF-8?q?fix:=20CI/CD=20yml=20=ED=95=A9=EC=B9=98?= =?UTF-8?q?=EA=B8=B0(=EC=9E=84=EC=8B=9C)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 39 ++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index d917a881..7c3c3c6d 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -51,4 +51,41 @@ jobs: - name: Tear down Docker Compose if: always() - run: docker-compose down \ No newline at end of file + run: docker-compose down + + # DI + - name: Set Yaml + uses: microsoft/variable-substitution@v1 + with: + files: ./src/main/resources/application-prod.yml + env: + spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} + spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} + spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }} + spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }} + spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }} + + - name: Grant execute permission for gradlew + run: chmod +x ./gradlew + shell: bash + + - name: Make Zip file + run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh + shell: bash + + - name: AWS credential setting + uses: aws-actions/configure-aws-credentials@v3 + with: + aws-region: ${{secrets.AWS_KJH_REGION}} + aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}} + aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} + + - name: Upload to S3 + run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + + - name: EC2 Deploy + run: aws deploy create-deployment + --application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}} + --deployment-config-name CodeDeployDefault.AllAtOnce + --deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}} + --s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip \ No newline at end of file From 9d829d4764eecaa58fd27327917d6f58972bf81b Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 10:36:02 +0900 Subject: [PATCH 32/40] =?UTF-8?q?fix:=20prod.yml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80=20=EC=BD=94=EB=93=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 7c3c3c6d..fa6e99ee 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -54,6 +54,11 @@ jobs: run: docker-compose down # DI + - name: Ensure application-prod.yml exists + run: | + mkdir -p ./src/main/resources/ + touch ./src/main/resources/application-prod.yml + - name: Set Yaml uses: microsoft/variable-substitution@v1 with: From 7caa484b314ed0fbec7492450f0fb094be59662f Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 10:44:54 +0900 Subject: [PATCH 33/40] =?UTF-8?q?fix:=20prod.yml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=A3=A8=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index fa6e99ee..2771a074 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -55,14 +55,12 @@ jobs: # DI - name: Ensure application-prod.yml exists - run: | - mkdir -p ./src/main/resources/ - touch ./src/main/resources/application-prod.yml + run: touch ./application-prod.yml - name: Set Yaml uses: microsoft/variable-substitution@v1 with: - files: ./src/main/resources/application-prod.yml + files: ./application-prod.yml env: spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} From b3178b05ec744d6ad984eccb3a5f9f85a4a8d017 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 11:38:33 +0900 Subject: [PATCH 34/40] =?UTF-8?q?fix:=20prod.yml=20=EA=B3=B5=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=A7=81=EC=A0=91=20=EB=84=A3=EA=B3=A0=20=ED=85=8C?= =?UTF-8?q?=EC=8A=A4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 2 -- application-prod.yml | 0 2 files changed, 2 deletions(-) create mode 100644 application-prod.yml diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 2771a074..698cd7da 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -54,8 +54,6 @@ jobs: run: docker-compose down # DI - - name: Ensure application-prod.yml exists - run: touch ./application-prod.yml - name: Set Yaml uses: microsoft/variable-substitution@v1 diff --git a/application-prod.yml b/application-prod.yml new file mode 100644 index 00000000..e69de29b From e0043536f85ece32972b28d45ab97ae84705c5b4 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 11:44:16 +0900 Subject: [PATCH 35/40] =?UTF-8?q?fix:=20prod.yml=20=EA=B3=B5=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EB=A3=A8=ED=8A=B8=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 698cd7da..813a9c5b 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -58,7 +58,7 @@ jobs: - name: Set Yaml uses: microsoft/variable-substitution@v1 with: - files: ./application-prod.yml + files: application-prod.yml env: spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} From 3c338780d332ddce1f8b7bd3bbfb6cbc4ef62283 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 11:55:28 +0900 Subject: [PATCH 36/40] =?UTF-8?q?fix:=20prod.yml=20=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=82=B4=EC=9A=A9=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 3 +-- application-prod.yml | 9 +++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 813a9c5b..38f07fc2 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -54,11 +54,10 @@ jobs: run: docker-compose down # DI - - name: Set Yaml uses: microsoft/variable-substitution@v1 with: - files: application-prod.yml + files: ./application-prod.yml env: spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} diff --git a/application-prod.yml b/application-prod.yml index e69de29b..65bbc045 100644 --- a/application-prod.yml +++ b/application-prod.yml @@ -0,0 +1,9 @@ +spring: + datasource: + url: "" + username: "" + password: "" + data: + redis: + host: "" + port: "" \ No newline at end of file From d796615efbde4c76870dc23981677560d8cd74d5 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 12:03:06 +0900 Subject: [PATCH 37/40] =?UTF-8?q?fix:=20bucket=20=EC=9D=B4=EB=A6=84=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index 38f07fc2..f400131f 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -81,7 +81,7 @@ jobs: aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} - name: Upload to S3 - run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_KJH_S3_BUCKET }}/$GITHUB_SHA.zip - name: EC2 Deploy run: aws deploy create-deployment From b8424880e2582561253e6218f5ef98c51417dc44 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 15:01:36 +0900 Subject: [PATCH 38/40] =?UTF-8?q?fix:=20CI/CD=20=EB=B6=84=EB=A6=AC=20git?= =?UTF-8?q?=20token=20=EB=B6=80=EC=97=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/itcast-build-and-deploy.yml | 7 +++- .github/workflows/itcast-build-and-test.yml | 39 +------------------ 2 files changed, 7 insertions(+), 39 deletions(-) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/itcast-build-and-deploy.yml index 916b6421..7ee866e8 100644 --- a/.github/workflows/itcast-build-and-deploy.yml +++ b/.github/workflows/itcast-build-and-deploy.yml @@ -16,6 +16,11 @@ jobs: packages: write steps: + - name: Checkout repository + uses: actions/checkout@v2 + with: + token: ${{ secrets.KJH_TOKEN }} + - name: Checkout code uses: actions/checkout@v3 @@ -77,7 +82,7 @@ jobs: aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} - name: Upload to S3 - run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_S3_BUCKET }}/$GITHUB_SHA.zip + run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_KJH_S3_BUCKET }}/$GITHUB_SHA.zip - name: EC2 Deploy run: aws deploy create-deployment diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/itcast-build-and-test.yml index f400131f..d917a881 100644 --- a/.github/workflows/itcast-build-and-test.yml +++ b/.github/workflows/itcast-build-and-test.yml @@ -51,41 +51,4 @@ jobs: - name: Tear down Docker Compose if: always() - run: docker-compose down - - # DI - - name: Set Yaml - uses: microsoft/variable-substitution@v1 - with: - files: ./application-prod.yml - env: - spring.datasource.url: ${{secrets.KJH_MYSQL_URL}} - spring.datasource.username: ${{ secrets.KJH_DB_USERNAME }} - spring.datasource.password: ${{ secrets.KJH_DB_PASSWORD }} - spring.data.redis.host: ${{ secrets.KJH_REDIS_HOST }} - spring.data.redis.port: ${{ secrets.KJH_REDIS_PORT }} - - - name: Grant execute permission for gradlew - run: chmod +x ./gradlew - shell: bash - - - name: Make Zip file - run: zip -r $GITHUB_SHA.zip build/libs/*.jar appspec.yml scripts/deploy.sh - shell: bash - - - name: AWS credential setting - uses: aws-actions/configure-aws-credentials@v3 - with: - aws-region: ${{secrets.AWS_KJH_REGION}} - aws-access-key-id: ${{secrets.AWS_KJH_ACCESS_KEY}} - aws-secret-access-key: ${{secrets.AWS_KJH_SECRET_ACCESS_KEY}} - - - name: Upload to S3 - run: aws s3 cp ./$GITHUB_SHA.zip s3://${{ secrets.AWS_KJH_S3_BUCKET }}/$GITHUB_SHA.zip - - - name: EC2 Deploy - run: aws deploy create-deployment - --application-name ${{secrets.AWS_KJH_CODE_DEPLOY_APPLICATION}} - --deployment-config-name CodeDeployDefault.AllAtOnce - --deployment-group-name ${{secrets.AWS_KJH_CODE_DEPLOY_GROUP}} - --s3-location bucket=${{secrets.AWS_KJH_S3_BUCKET}},key=$GITHUB_SHA.zip,bundleType=zip \ No newline at end of file + run: docker-compose down \ No newline at end of file From 68d14529ebcbcc2494752013245c28feae604951 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 18:02:57 +0900 Subject: [PATCH 39/40] =?UTF-8?q?fix:=20=ED=8C=8C=EC=9D=BC=EB=AA=85=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 --- .../{itcast-build-and-deploy.yml => ItcastBuildAndDeploy.yml} | 0 .../{itcast-build-and-test.yml => ItcastBuildAndTest.yml} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{itcast-build-and-deploy.yml => ItcastBuildAndDeploy.yml} (100%) rename .github/workflows/{itcast-build-and-test.yml => ItcastBuildAndTest.yml} (100%) diff --git a/.github/workflows/itcast-build-and-deploy.yml b/.github/workflows/ItcastBuildAndDeploy.yml similarity index 100% rename from .github/workflows/itcast-build-and-deploy.yml rename to .github/workflows/ItcastBuildAndDeploy.yml diff --git a/.github/workflows/itcast-build-and-test.yml b/.github/workflows/ItcastBuildAndTest.yml similarity index 100% rename from .github/workflows/itcast-build-and-test.yml rename to .github/workflows/ItcastBuildAndTest.yml From 9257b4bf9594abc402f67dc8c41fc9511e3a7b03 Mon Sep 17 00:00:00 2001 From: kimjihye Date: Fri, 20 Dec 2024 18:15:50 +0900 Subject: [PATCH 40/40] =?UTF-8?q?fix:=20=ED=8C=8C=EC=9D=BC=EB=AA=85=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/ItcastBuildAndDeploy.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ItcastBuildAndDeploy.yml b/.github/workflows/ItcastBuildAndDeploy.yml index 7ee866e8..afce0faf 100644 --- a/.github/workflows/ItcastBuildAndDeploy.yml +++ b/.github/workflows/ItcastBuildAndDeploy.yml @@ -8,8 +8,8 @@ on: jobs: deploy: - if: > - github.event.workflow_run.conclusion == 'success' +# if: > +# github.event.workflow_run.conclusion == 'success' runs-on: ubuntu-latest permissions: contents: read