-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
112 changed files
with
5,602 additions
and
3 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,66 @@ | ||
name: Deploy To EC2 | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- dev | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Github Repository 파일 불러오기 | ||
uses: actions/checkout@v4 | ||
|
||
- name: JDK 17버전 설치 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: temurin | ||
java-version: 17 | ||
|
||
- name: yml 파일 생성 | ||
run: | | ||
mkdir -p ./src/main/resources | ||
echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.yml | ||
echo "${{ secrets.APPLICATION_JWT }}" > ./src/main/resources/application-jwt.yml | ||
echo "${{ secrets.APPLICATION_OAUTH }}" > ./src/main/resources/application-oauth.yml | ||
- name: gradlew 파일 실행 권한 부여 | ||
run: chmod +x ./gradlew | ||
|
||
- name: 테스트 및 빌드 | ||
run: ./gradlew clean build | ||
|
||
- name: AWS Resource에 접근할 수 있게 AWS credentials 설정 | ||
uses: aws-actions/configure-aws-credentials@v4 | ||
with: | ||
aws-region: ap-northeast-2 | ||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
|
||
- name: ECR에 로그인 | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Docker 이미지 생성 | ||
run: docker build -t locavel-server . | ||
|
||
- name: Docker 이미지에 Tag 붙이기 | ||
run: docker tag locavel-server ${{ steps.login-ecr.outputs.registry }}/locavel-server:latest | ||
|
||
- name: ECR에 Docker 이미지 Push 하기 | ||
run: docker push ${{ steps.login-ecr.outputs.registry }}/locavel-server:latest | ||
|
||
|
||
- name: SSH로 EC2에 접속하기 | ||
uses: appleboy/[email protected] | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_PRIVATE_KEY }} | ||
script_stop: true | ||
script: | | ||
docker stop locavel-server || true | ||
docker rm locavel-server || true | ||
docker pull ${{ steps.login-ecr.outputs.registry }}/locavel-server:latest | ||
docker run -d --name locavel-server -p 8080:8080 ${{ steps.login-ecr.outputs.registry }}/locavel-server:latest |
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 |
---|---|---|
|
@@ -35,3 +35,8 @@ out/ | |
|
||
### VS Code ### | ||
.vscode/ | ||
# YAML files | ||
*.yml | ||
|
||
# CI/CD 관련 deploy.yml 파일 제외 | ||
!.github/workflows/deploy.yml |
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,4 @@ | ||
FROM eclipse-temurin:17-jdk-alpine | ||
COPY ./build/libs/*SNAPSHOT.jar project.jar | ||
ENTRYPOINT ["java", "-jar", "project.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
Binary file not shown.
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,169 @@ | ||
package com.example.locavel; | ||
|
||
import com.example.locavel.domain.Region; | ||
import com.example.locavel.domain.Term; | ||
import com.example.locavel.repository.RegionRepository; | ||
import org.springframework.boot.CommandLineRunner; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
//더미 데이터 생성용 | ||
@Configuration | ||
public class MakeInitData { | ||
|
||
@Bean // 지역별 엔티티 생성 | ||
public CommandLineRunner loadRegionData(RegionRepository regionRepository) { | ||
return args -> { | ||
Region region1 = Region.builder() | ||
.name("강남구") | ||
.build(); | ||
Region region2 = Region.builder() | ||
.name("강동구") | ||
.build(); | ||
Region region3 = Region.builder() | ||
.name("강북구") | ||
.build(); | ||
Region region4 = Region.builder() | ||
.name("강서구") | ||
.build(); | ||
Region region5 = Region.builder() | ||
.name("관악구") | ||
.build(); | ||
Region region6 = Region.builder() | ||
.name("광진구") | ||
.build(); | ||
Region region7 = Region.builder() | ||
.name("구로구") | ||
.build(); | ||
Region region8 = Region.builder() | ||
.name("금천구") | ||
.build(); | ||
Region region9 = Region.builder() | ||
.name("노원구") | ||
.build(); | ||
Region region10 = Region.builder() | ||
.name("도봉구") | ||
.build(); | ||
Region region11 = Region.builder() | ||
.name("동대문구") | ||
.build(); | ||
Region region12 = Region.builder() | ||
.name("동작구") | ||
.build(); | ||
Region region13 = Region.builder() | ||
.name("마포구") | ||
.build(); | ||
Region region14 = Region.builder() | ||
.name("서대문구") | ||
.build(); | ||
Region region15 = Region.builder() | ||
.name("서초구") | ||
.build(); | ||
Region region16 = Region.builder() | ||
.name("성동구") | ||
.build(); | ||
Region region17 = Region.builder() | ||
.name("성북구") | ||
.build(); | ||
Region region18 = Region.builder() | ||
.name("송파구") | ||
.build(); | ||
Region region19 = Region.builder() | ||
.name("양천구") | ||
.build(); | ||
Region region20 = Region.builder() | ||
.name("영등포구") | ||
.build(); | ||
Region region21 = Region.builder() | ||
.name("용산구") | ||
.build(); | ||
Region region22 = Region.builder() | ||
.name("은평구") | ||
.build(); | ||
Region region23 = Region.builder() | ||
.name("종로구") | ||
.build(); | ||
Region region24 = Region.builder() | ||
.name("중구") | ||
.build(); | ||
Region region25 = Region.builder() | ||
.name("중랑구") | ||
.build(); | ||
if (regionRepository.findByName(region1.getName()) == null) { | ||
regionRepository.save(region1); | ||
} | ||
if (regionRepository.findByName(region2.getName()) == null) { | ||
regionRepository.save(region2); | ||
} | ||
if (regionRepository.findByName(region3.getName()) == null) { | ||
regionRepository.save(region3); | ||
} | ||
if (regionRepository.findByName(region4.getName()) == null) { | ||
regionRepository.save(region4); | ||
} | ||
if (regionRepository.findByName(region5.getName()) == null) { | ||
regionRepository.save(region5); | ||
} | ||
if (regionRepository.findByName(region6.getName()) == null) { | ||
regionRepository.save(region6); | ||
} | ||
if (regionRepository.findByName(region7.getName()) == null) { | ||
regionRepository.save(region7); | ||
} | ||
if (regionRepository.findByName(region8.getName()) == null) { | ||
regionRepository.save(region8); | ||
} | ||
if (regionRepository.findByName(region9.getName()) == null) { | ||
regionRepository.save(region9); | ||
} | ||
if (regionRepository.findByName(region10.getName()) == null) { | ||
regionRepository.save(region10); | ||
} | ||
if (regionRepository.findByName(region11.getName()) == null) { | ||
regionRepository.save(region11); | ||
} | ||
if (regionRepository.findByName(region12.getName()) == null) { | ||
regionRepository.save(region12); | ||
} | ||
if (regionRepository.findByName(region13.getName()) == null) { | ||
regionRepository.save(region13); | ||
} | ||
if (regionRepository.findByName(region14.getName()) == null) { | ||
regionRepository.save(region14); | ||
} | ||
if (regionRepository.findByName(region15.getName()) == null) { | ||
regionRepository.save(region15); | ||
} | ||
if (regionRepository.findByName(region16.getName()) == null) { | ||
regionRepository.save(region16); | ||
} | ||
if (regionRepository.findByName(region17.getName()) == null) { | ||
regionRepository.save(region17); | ||
} | ||
if (regionRepository.findByName(region18.getName()) == null) { | ||
regionRepository.save(region18); | ||
} | ||
if (regionRepository.findByName(region19.getName()) == null) { | ||
regionRepository.save(region19); | ||
} | ||
if (regionRepository.findByName(region20.getName()) == null) { | ||
regionRepository.save(region20); | ||
} | ||
if (regionRepository.findByName(region21.getName()) == null) { | ||
regionRepository.save(region21); | ||
} | ||
if (regionRepository.findByName(region22.getName()) == null) { | ||
regionRepository.save(region22); | ||
} | ||
if (regionRepository.findByName(region23.getName()) == null) { | ||
regionRepository.save(region23); | ||
} | ||
if (regionRepository.findByName(region24.getName()) == null) { | ||
regionRepository.save(region24); | ||
} | ||
if (regionRepository.findByName(region25.getName()) == null) { | ||
regionRepository.save(region25); | ||
} | ||
}; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
src/main/java/com/example/locavel/apiPayload/ApiResponse.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,38 @@ | ||
package com.example.locavel.apiPayload; | ||
|
||
import com.example.locavel.apiPayload.code.BaseCode; | ||
import com.example.locavel.apiPayload.code.status.SuccessStatus; | ||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
@JsonPropertyOrder({"isSuccess", "code", "message", "result"}) | ||
public class ApiResponse<T> { | ||
|
||
@JsonProperty("isSuccess") | ||
private final Boolean isSuccess; | ||
private final String code; | ||
private final String message; | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
private T result; //generic type: 어떤 값이 올지 모르기 때문에 generic 으로 선언, 추후에 외부에서 지정 가능 | ||
|
||
|
||
// 성공한 경우 응답 생성 | ||
|
||
public static <T> ApiResponse<T> onSuccess(T result){ | ||
return new ApiResponse<>(true, SuccessStatus._OK.getCode() , SuccessStatus._OK.getMessage(), result); | ||
} | ||
|
||
public static <T> ApiResponse<T> of(BaseCode code, T result){ | ||
return new ApiResponse<>(true, code.getReasonHttpStatus().getCode() , code.getReasonHttpStatus().getMessage(), result); | ||
} | ||
|
||
// 실패한 경우 응답 생성 | ||
public static <T> ApiResponse<T> onFailure(String code, String message, T data){ | ||
return new ApiResponse<>(false, code, message, data); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/locavel/apiPayload/code/BaseCode.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,7 @@ | ||
package com.example.locavel.apiPayload.code; | ||
|
||
public interface BaseCode { | ||
public ReasonDTO getReason(); | ||
|
||
public ReasonDTO getReasonHttpStatus(); | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/com/example/locavel/apiPayload/code/BaseErrorCode.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,7 @@ | ||
package com.example.locavel.apiPayload.code; | ||
|
||
public interface BaseErrorCode { | ||
public ErrorReasonDTO getReason(); | ||
|
||
public ErrorReasonDTO getReasonHttpStatus(); | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/example/locavel/apiPayload/code/ErrorReasonDTO.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,18 @@ | ||
package com.example.locavel.apiPayload.code; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@Builder | ||
public class ErrorReasonDTO { | ||
|
||
private HttpStatus httpStatus; | ||
|
||
private final boolean isSuccess; | ||
private final String code; | ||
private final String message; | ||
|
||
public boolean getIsSuccess(){return isSuccess;} | ||
} |
18 changes: 18 additions & 0 deletions
18
src/main/java/com/example/locavel/apiPayload/code/ReasonDTO.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,18 @@ | ||
package com.example.locavel.apiPayload.code; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import org.springframework.http.HttpStatus; | ||
|
||
@Getter | ||
@Builder | ||
public class ReasonDTO { | ||
|
||
private HttpStatus httpStatus; | ||
|
||
private final boolean isSuccess; | ||
private final String code; | ||
private final String message; | ||
|
||
public boolean getIsSuccess(){return isSuccess;} | ||
} |
Oops, something went wrong.