From 9ba1bdb95fbbf233436ea262e4acb8bd8cb190d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=AF=BC=EC=B0=AC=EA=B8=B0?= Date: Mon, 3 Jun 2024 08:07:26 +0900 Subject: [PATCH] feat: Setting logback (#15) --- .../{showPot-ci.yml => showPot-dev-ci.yml} | 21 ++++--- .github/workflows/showPot-prod-ci.yml | 56 ++++++++++++++++++ app/build.gradle | 3 + app/src/main/resources/application-dev.yml | 6 ++ app/src/main/resources/application-prod.yml | 8 ++- app/src/main/resources/logback-spring.xml | 59 +++++++++++++++++++ 6 files changed, 145 insertions(+), 8 deletions(-) rename .github/workflows/{showPot-ci.yml => showPot-dev-ci.yml} (66%) create mode 100644 .github/workflows/showPot-prod-ci.yml create mode 100644 app/src/main/resources/logback-spring.xml diff --git a/.github/workflows/showPot-ci.yml b/.github/workflows/showPot-dev-ci.yml similarity index 66% rename from .github/workflows/showPot-ci.yml rename to .github/workflows/showPot-dev-ci.yml index 3060040f..4bc7415b 100644 --- a/.github/workflows/showPot-ci.yml +++ b/.github/workflows/showPot-dev-ci.yml @@ -1,10 +1,9 @@ -name: ShowPot-CI +name: ShowPot-Dev-CI on: pull_request: branches: - develop - - prod jobs: build: @@ -24,6 +23,14 @@ jobs: - name: Setup Gradle uses: gradle/actions/setup-gradle@v3 + - name: Copy Secrets + env: + ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} + SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} + run: + echo $ACCESS_KEY > ./app/src/main/resources/application-dev.yml + echo $SECRET_KEY > ./app/src/main/resources/application-dev.yml + - name: Build with Gradle Wrapper run: ./gradlew clean build @@ -42,8 +49,8 @@ jobs: uses: sarisia/actions-status-discord@v1 if: failure() with: - title: ❗️Backend CI failed ❗️ - webhook: ${{ secrets.DISCORD_WEBHOOK }} - color: FF0000 - username: showPot-Bot - avatar_url: ${{ secrets.DISCORD_NOTIFICATION_FAILED_AVATAR_URL }} + title: ❗️Backend CI failed ❗️ + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} + color: FF0000 + username: showPot-Bot + avatar_url: ${{ secrets.DISCORD_NOTIFICATION_FAILED_AVATAR_URL }} diff --git a/.github/workflows/showPot-prod-ci.yml b/.github/workflows/showPot-prod-ci.yml new file mode 100644 index 00000000..37d5ad49 --- /dev/null +++ b/.github/workflows/showPot-prod-ci.yml @@ -0,0 +1,56 @@ +name: ShowPot-Prod-CI + +on: + pull_request: + branches: + - prod + +jobs: + build: + runs-on: ubuntu-latest + permissions: + contents: read + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK 17 + uses: actions/setup-java@v4 + with: + java-version: '17' + distribution: 'liberica' + cache: gradle + + - name: Setup Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Copy Secrets + env: + ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY }} + SECRET_KEY: ${{ secrets.AWS_SECRET_KEY }} + run: + echo $ACCESS_KEY > ./app/src/main/resources/application-prod.yml + echo $SECRET_KEY > ./app/src/main/resources/application-prod.yml + + - name: Build with Gradle Wrapper + run: ./gradlew clean build + + - name: Backend CI Discord Notification + uses: sarisia/actions-status-discord@v1 + if: success() + with: + title: ✅ Backend CI success ✅ + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} + content: "<@1084774841460215839> <@281597829636423682> ShoPot 이슈 혹은 PR을 확인해주세요!" + color: 00FF00 + username: showPot-Bot + avatar_url: ${{ secrets.DISCORD_NOTIFICATION_SUCCESS_AVATAR_URL }} + + - name: Backend CI Discord Notification + uses: sarisia/actions-status-discord@v1 + if: failure() + with: + title: ❗️Backend CI failed ❗️ + webhook: ${{ secrets.DISCORD_WEBHOOK_URL }} + color: FF0000 + username: showPot-Bot + avatar_url: ${{ secrets.DISCORD_NOTIFICATION_FAILED_AVATAR_URL }} diff --git a/app/build.gradle b/app/build.gradle index 96d6002d..24935494 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -22,4 +22,7 @@ dependencies { // docker-compose developmentOnly 'org.springframework.boot:spring-boot-docker-compose' testAndDevelopmentOnly 'org.springframework.boot:spring-boot-docker-compose' + + // aws logs + implementation 'ca.pjer:logback-awslogs-appender:1.6.0' } \ No newline at end of file diff --git a/app/src/main/resources/application-dev.yml b/app/src/main/resources/application-dev.yml index b71534c2..bdf44852 100644 --- a/app/src/main/resources/application-dev.yml +++ b/app/src/main/resources/application-dev.yml @@ -2,3 +2,9 @@ spring: docker: compose: enabled: false + +cloud: + aws: + credentials: + accessKey: ${ACCESS_KEY} + secretKey: ${SECRET_KEY} diff --git a/app/src/main/resources/application-prod.yml b/app/src/main/resources/application-prod.yml index 9fd2af10..448eca30 100644 --- a/app/src/main/resources/application-prod.yml +++ b/app/src/main/resources/application-prod.yml @@ -1,4 +1,10 @@ spring: docker: compose: - enabled: false \ No newline at end of file + enabled: false + +cloud: + aws: + credentials: + accessKey: ${ACCESS_KEY} + secretKey: ${SECRET_KEY} \ No newline at end of file diff --git a/app/src/main/resources/logback-spring.xml b/app/src/main/resources/logback-spring.xml new file mode 100644 index 00000000..a3b8c3a6 --- /dev/null +++ b/app/src/main/resources/logback-spring.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + ${CONSOLE_LOG_PATTERN} + + + + + + [%thread] [%date] [%level] [%file:%line] - %msg%n + + + showpot/${ACTIVE_PROFILE} + ap-northeast-2 + 50 + 60000 + 5000 + 0 + ${AWS_ACCESS_KEY} + ${AWS_SECRET_KEY} + + + WARN + + + + UTF-8 + %d{HH:mm:ss.SSS} [%thread] [%5level] %logger{35}[%method:%line] %m%n + + + + + + + + + + + + + + + \ No newline at end of file