From e06e14d878e19757af7eafea86d1f80c009019eb Mon Sep 17 00:00:00 2001 From: Jsplix Date: Sun, 22 Jun 2025 20:33:21 +0900 Subject: [PATCH 1/5] chore: add application.yml to .gitignore --- .github/workflows/cd.yml | 0 .github/workflows/ci.yml | 0 .gitignore | 3 +++ Dockerfile | 0 src/main/resources/{application.properties => application.yml} | 0 5 files changed, 3 insertions(+) create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml create mode 100644 Dockerfile rename src/main/resources/{application.properties => application.yml} (100%) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore index c2065bc..90492ca 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,9 @@ build/ !**/src/main/**/build/ !**/src/test/**/build/ +### APPLICATION ### +src/main/resources/application.yml + ### STS ### .apt_generated .classpath diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/application.properties b/src/main/resources/application.yml similarity index 100% rename from src/main/resources/application.properties rename to src/main/resources/application.yml From 6547784c73ee903c2de8b1ecd5c6aed299c53b62 Mon Sep 17 00:00:00 2001 From: Jsplix Date: Mon, 23 Jun 2025 00:35:58 +0900 Subject: [PATCH 2/5] chore: database dependency settings --- build.gradle | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/build.gradle b/build.gradle index c512544..110cc46 100644 --- a/build.gradle +++ b/build.gradle @@ -30,8 +30,15 @@ dependencies { annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' testRuntimeOnly 'org.junit.platform:junit-platform-launcher' + + // mysql + implementation 'com.mysql:mysql-connector-j' } tasks.named('test') { useJUnitPlatform() } + +jar { + enabled = false +} From 7bcc53f6eb335c884ae5e54c51f8d863d64d8450 Mon Sep 17 00:00:00 2001 From: Jsplix Date: Mon, 23 Jun 2025 00:37:42 +0900 Subject: [PATCH 3/5] chore: create dockerfile for deployment configuration --- Dockerfile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Dockerfile b/Dockerfile index e69de29..060c615 100644 --- a/Dockerfile +++ b/Dockerfile @@ -0,0 +1,4 @@ +FROM openjdk:17-jdk +ARG JAR_FILE=build/libs/*.jar +COPY ${JAR_FILE} app.jar +ENTRYPOINT ["java", "-Dspring.profiles.active=docker", "-jar", "app.jar"] \ No newline at end of file From 95f0ba39c2b77578b7f0b58448fd4ab22da5f616 Mon Sep 17 00:00:00 2001 From: Jsplix Date: Mon, 23 Jun 2025 00:38:19 +0900 Subject: [PATCH 4/5] chore: ci&cd pipeline implementation --- .github/workflows/cd.yml | 83 ++++++++++++++++++++++++++++++++++++++++ .github/workflows/ci.yml | 59 ++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e69de29..0f55de6 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -0,0 +1,83 @@ +name: Java CD with Gradle + +on: + push: + branches: [ "main" ] + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + environment: + description: 'Environment to run tests against' + type: environment + required: false + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + # 1. checkout + - uses: actions/checkout@v3 + + # 2. Java 17 설정 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + # 3. properties 설정 + - name: Set up application.yml + run: | + mkdir -p src/main/resources + echo "${{ secrets.APPLICATION }}" > src/main/resources/application.yml + + # 4. gradlew build + - name: Build with Gradle + uses: gradle/gradle-build-action@v2 # v2.6.0 + with: + arguments: build + + # 5. Docker 이미지 빌드 + - name: docker image build + run: docker build -t ${{ secrets.DOCKER_USERNAME }}/warmlink-was . + + # 6. DockerHub 로그인 + - name: docker login + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + # 7. Docker Hub 이미지 푸시 + - name: docker Hub push + run: docker push ${{ secrets.DOCKER_USERNAME }}/warmlink-was + + # 8. EC2 pull + - name: Deploy + uses: appleboy/ssh-action@master + with: + host: ${{ secrets.AWS_HOST }} + username: ${{ secrets.AWS_USERNAME }} + key: ${{ secrets.AWS_KEY }} + port: ${{ secrets.AWS_PORT }} + script: | + sudo docker stop warmlink-was + sudo docker rm warmlink-was + sudo docker image prune -af + sudo docker pull ${{ secrets.DOCKER_USERNAME }}/warmlink-was + sudo docker run -d -p 8080:8080 --name warmlink-was -e TZ=Asia/Seoul ${{ secrets.DOCKER_USERNAME }}/warmlink-was \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e69de29..ae4ffde 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -0,0 +1,59 @@ +name: Java CI with Gradle + +on: + pull_request: + branches: [ "main" ] + workflow_dispatch: + inputs: + logLevel: + description: 'Log level' + required: true + default: 'warning' + type: choice + options: + - info + - warning + - debug + tags: + description: 'Test scenario tags' + required: false + type: boolean + environment: + description: 'Environment to run tests against' + type: environment + required: false + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + # 1. checkout + - uses: actions/checkout@v3 + + # 2. Java 17 설정 + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + # 3. AWS Credentials 설정 + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} + aws-region: ${{ secrets.AWS_REGION }} + + # 4. gradlew 실행 권한 설정 + - name: Run chmod to make gradlew executable + run: chmod +x ./gradlew + + # 5. gradlew build + - name: Build with Gradle + uses: gradle/gradle-build-action@v2 + with: + arguments: build \ No newline at end of file From e016785b8004681cd4c0f43e1a92f3fbb45c5ce0 Mon Sep 17 00:00:00 2001 From: Jsplix Date: Mon, 23 Jun 2025 00:44:28 +0900 Subject: [PATCH 5/5] fix: fixing ci settings --- .github/workflows/ci.yml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ae4ffde..523bccb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,13 +40,11 @@ jobs: java-version: '17' distribution: 'temurin' - # 3. AWS Credentials 설정 - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }} - aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} - aws-region: ${{ secrets.AWS_REGION }} + # 3. properties 설정 + - name: Set up application.yml + run: | + mkdir -p src/main/resources + echo "${{ secrets.APPLICATION }}" > src/main/resources/application.yml # 4. gradlew 실행 권한 설정 - name: Run chmod to make gradlew executable