-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
190 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: main branch cd | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
|
||
env: | ||
MAIN_YML_PATH: ./src/main/resources/application.yml | ||
PROD_YML_PATH: ./src/main/resources/application-prod.yml | ||
|
||
jobs: | ||
build-and-push-image: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: application.yml setting | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: ${{ env.MAIN_YML_PATH }} | ||
env: | ||
coolsms.api.key: ${{ secrets.COOLSMS_API_KEY }} | ||
coolsms.api.secret: ${{ secrets.COOLSMS_API_SECRET }} | ||
coolsms.api.from-number: ${{ secrets.COOLSMS_API_FROM_NUMBER }} | ||
|
||
- name: application-prod.yml setting | ||
uses: microsoft/variable-substitution@v1 | ||
with: | ||
files: ${{ env.PROD_YML_PATH }} | ||
env: | ||
spring.datasource.url: ${{ secrets.RDS_URL }} | ||
spring.datasource.username: ${{ secrets.PROD_DB_USERNAME }} | ||
spring.datasource.password: ${{ secrets.PROD_DB_PASSWORD }} | ||
|
||
- name: Cache Gradle packages | ||
uses: actions/cache@v1 | ||
with: | ||
path: ~/.gradle/caches | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} | ||
restore-keys: ${{ runner.os }}-gradle | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Clean and Build with Gradle | ||
run: ./gradlew clean build -x test | ||
|
||
- name: Docker build & push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/insurance_system_prod . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/insurance_system_prod | ||
- name: Deploy EC2 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST_IP }} | ||
username: ubuntu | ||
key: ${{ secrets.EC2_KEY }} | ||
port: 22 | ||
script: | | ||
docker stop insurance_system_prod | ||
docker rm insurance_system_prod | ||
docker rmi choihyeok/insurance_system_prod | ||
docker pull choihyeok/insurance_system_prod | ||
docker run -d -p 80:8080 --name insurance_system_prod choihyeok/insurance_system_prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# 테스트 서버 빌드 스크립트 | ||
# jar 파일 빌드 | ||
FROM eclipse-temurin:17 as builder | ||
|
||
COPY gradlew . | ||
COPY gradle gradle | ||
COPY build.gradle . | ||
COPY settings.gradle . | ||
COPY src src | ||
RUN chmod +x ./gradlew | ||
RUN ./gradlew bootjar | ||
|
||
# jar 실행 | ||
FROM eclipse-temurin:17-jre as runtime | ||
|
||
COPY --from=builder build/libs/*.jar app.jar | ||
|
||
ENV PROFILE prod | ||
|
||
EXPOSE 8080 | ||
|
||
ENTRYPOINT ["java", "-Dspring.profiles.active=${PROFILE}", "-jar", "/app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
src/main/java/aplus/insurancesystem/common/service/Esms.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package aplus.insurancesystem.common.service; | ||
|
||
import lombok.Getter; | ||
import lombok.RequiredArgsConstructor; | ||
|
||
@Getter | ||
@RequiredArgsConstructor | ||
public enum Esms { | ||
COMPENSATION_CLAIM_COMPLETED("보상금 청구가 완료되었습니다. 손해사정에는 수일이 걸릴 수 있습니다."), | ||
|
||
SURVEY_COMPLETED("손해사정이 완료되었습니다. 홈페이지에서 결과를 확인해주세요."), | ||
|
||
INSURANCE_APPLICATION_APPROVED("보험 가입 심사가 완료되었습니다. 홈페이지에서 결과를 확인해주세요."); | ||
|
||
private final String message; | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/aplus/insurancesystem/common/service/MessageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package aplus.insurancesystem.common.service; | ||
|
||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.transaction.annotation.Transactional; | ||
|
||
import net.nurigo.sdk.NurigoApp; | ||
import net.nurigo.sdk.message.model.Message; | ||
import net.nurigo.sdk.message.request.SingleMessageSendingRequest; | ||
import net.nurigo.sdk.message.response.SingleMessageSentResponse; | ||
import net.nurigo.sdk.message.service.DefaultMessageService; | ||
|
||
@Service | ||
@Transactional(readOnly = true) | ||
public class MessageService { | ||
|
||
private final DefaultMessageService messageService; | ||
|
||
private String fromNumber; | ||
|
||
public MessageService(@Value("${coolsms.api.key}") String apiKey, | ||
@Value("${coolsms.api.secret}") String apiSecretKey, | ||
@Value("${coolsms.api.from-number}") String fromNumber) { | ||
this.messageService = NurigoApp.INSTANCE.initialize(apiKey, apiSecretKey, "https://api.coolsms.co.kr"); | ||
this.fromNumber = fromNumber; | ||
} | ||
|
||
public SingleMessageSentResponse sendOne(String to, Esms esms) { | ||
Message message = new Message(); | ||
// 발신번호(fromNumber) 및 수신번호(to)는 반드시 01012345678 형태로 입력되어야 함 | ||
message.setFrom(fromNumber); | ||
message.setTo(to); | ||
message.setText("[A+보험사] " + esms.getMessage()); | ||
|
||
SingleMessageSentResponse response = this.messageService.sendOne(new SingleMessageSendingRequest(message)); | ||
return response; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,4 +15,4 @@ spring: | |
decorator: | ||
datasource: | ||
p6spy: | ||
enable-logging: true | ||
enable-logging: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
spring: | ||
datasource: | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
url: | ||
username: | ||
password: | ||
|
||
jpa: | ||
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect | ||
open-in-view: false | ||
hibernate: | ||
ddl-auto: validate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters