From 797c171299396e4f0029d2a30273f8ee9d19926f Mon Sep 17 00:00:00 2001 From: seo-young Date: Thu, 15 Feb 2024 15:59:59 +0900 Subject: [PATCH 1/4] =?UTF-8?q?[chore]=20application.yml=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/resources/application.properties | 1 - src/main/resources/application.yml | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) delete mode 100644 src/main/resources/application.properties create mode 100644 src/main/resources/application.yml diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties deleted file mode 100644 index 8b13789..0000000 --- a/src/main/resources/application.properties +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..22b5530 --- /dev/null +++ b/src/main/resources/application.yml @@ -0,0 +1,4 @@ +spring: + profiles: + include: + - prod From e8043c176b47f791d2c0196a7cdf86248ef75f11 Mon Sep 17 00:00:00 2001 From: seo-young Date: Thu, 15 Feb 2024 16:01:00 +0900 Subject: [PATCH 2/4] =?UTF-8?q?[chore]=20ci/cd=20=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/cd.yml | 32 ++++++++++++++++++++++++++++++++ .github/ci.yml | 0 2 files changed, 32 insertions(+) create mode 100644 .github/cd.yml create mode 100644 .github/ci.yml diff --git a/.github/cd.yml b/.github/cd.yml new file mode 100644 index 0000000..1dd5898 --- /dev/null +++ b/.github/cd.yml @@ -0,0 +1,32 @@ +name: ci + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/Setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Gradle Caching + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant Execute Permission For Gradlew + run: chmod +x gradlew + + - name: Build With Gradle + run: ./gradlew build \ No newline at end of file diff --git a/.github/ci.yml b/.github/ci.yml new file mode 100644 index 0000000..e69de29 From 933592a98b4883a043c2049570b947512e576aab Mon Sep 17 00:00:00 2001 From: seo-young Date: Thu, 15 Feb 2024 16:04:19 +0900 Subject: [PATCH 3/4] =?UTF-8?q?[chore]=20ci/cd=20=EA=B5=AC=EC=B6=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/ci.yml | 0 .github/workflows/cd.yml | 32 ++++++++++++++++++++++++++++ .github/{cd.yml => workflows/ci.yml} | 0 3 files changed, 32 insertions(+) delete mode 100644 .github/ci.yml create mode 100644 .github/workflows/cd.yml rename .github/{cd.yml => workflows/ci.yml} (100%) diff --git a/.github/ci.yml b/.github/ci.yml deleted file mode 100644 index e69de29..0000000 diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..959ad93 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,32 @@ +name: ci + +on: [push] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/Setup-java@v4 + with: + java-version: '17' + distribution: 'temurin' + + - name: Gradle Caching + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: Grant Execute Permission For Gradlew + run: chmod +x gradlew + + - name: Build With Gradle + run: ./gradlew build diff --git a/.github/cd.yml b/.github/workflows/ci.yml similarity index 100% rename from .github/cd.yml rename to .github/workflows/ci.yml From 65dc3754ec0679ac8c9520e33c94588265dc3c45 Mon Sep 17 00:00:00 2001 From: seo-young Date: Thu, 15 Feb 2024 16:08:04 +0900 Subject: [PATCH 4/4] =?UTF-8?q?[chore]=20cd=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/cd.yml | 45 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 959ad93..7b8b2e6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -1,6 +1,9 @@ -name: ci +name: cd -on: [push] +on: + push: + branches: + - main jobs: build: @@ -10,13 +13,13 @@ jobs: - uses: actions/checkout@v4 - name: Set up JDK 17 - uses: actions/Setup-java@v4 + uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - name: Gradle Caching - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.gradle/caches @@ -25,8 +28,42 @@ jobs: restore-keys: | ${{ runner.os }}-gradle- + - name: Make application-prod.yml + run: | + cd ./src/main/resources + touch ./application-prod.yml + echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.yml + shell: bash + - name: Grant Execute Permission For Gradlew run: chmod +x gradlew - name: Build With Gradle run: ./gradlew build + + - name: Docker build & push to docker repo + env: + DOCKER_PATH : .deploy/Dockerfile + run: | + docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} + docker build -f $DOCKER_PATH -t ${{ secrets.DOCKER_REPO }}/mookive . + docker push ${{ secrets.DOCKER_REPO }}/mookive + + - name: Deploy to Prob + uses: appleboy/ssh-action@master + id: deploy-prob + env: + DOCKER_COMPOSE : ".deploy/docker-compose.yml" + with: + host: ${{ secrets.EC2_HOST }} + username: ubuntu + key: ${{ secrets.EC2_KEY }} + envs: GITHUB_SHA + script: | + touch ./docker-compose.yml + echo "${{ secrets.DOCKER_COMPOSE }}" > ./docker-compose.yml + docker stop mookive + docker rm mookive + docker pull ${{ secrets.DOCKER_REPO }}/mookive + docker-compose up -d + docker image prune