Skip to content

Commit

Permalink
Feat#484 : main 브랜치로 서비스 배포 (#485)
Browse files Browse the repository at this point in the history
Co-authored-by: HyeonJun0530 <[email protected]>
Co-authored-by: 김현준 <[email protected]>
Co-authored-by: 홍성우 <[email protected]>
  • Loading branch information
4 people authored Apr 9, 2024
1 parent bc1bee2 commit 96600c4
Show file tree
Hide file tree
Showing 257 changed files with 16,282 additions and 20 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: CD Workflow
on:
push:
branches: [ "main" ]

jobs:
docker:
timeout-minutes: 10
runs-on: ubuntu-latest

steps:
# JDK setting - github actions에서 사용할 JDK 설정
- name: Checkout Code
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

# 환경별 properties 파일 생성 - API-KEY
- name: make application-API-KEY.properties
run: |
cd ./src/main/resources
touch ./application-API-KEY.properties
echo "${{ secrets.YML }}" > ./application-API-KEY.properties
shell: bash

# gradle 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x gradlew

# gradle build
- name: Build with Gradle
run: ./gradlew clean build -x test

# Docker
- name: Login DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Docker Image Build & Push
run: |
docker build -t ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }} -f Dockerfile .
docker push ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}
- name: EC2 Login
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST_NAME }}
username: ${{secrets.USER_NAME }}
key: ${{ secrets.SERVER_SSH_KEY }}
script: |
docker-compose down
docker image prune -f
docker rm $(docker ps -a -q)
docker pull ${{ secrets.DOCKERHUB_REGISTRY }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}
docker-compose up -d
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ out/

### VS Code ###
.vscode/
src/main/resources/application-API-KEY.properties
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM openjdk:17-alpine

WORKDIR /usr/src/app

ARG JAR_PATH=./build/libs

COPY ${JAR_PATH}/leaguehub-backend-0.0.1-SNAPSHOT.jar ${JAR_PATH}/leaguehub-backend-0.0.1-SNAPSHOT.jar

CMD ["java","-jar","-Dspring.profiles.active=prod","./build/libs/leaguehub-backend-0.0.1-SNAPSHOT.jar"]
262 changes: 262 additions & 0 deletions README.md

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,28 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'
implementation group: 'org.modelmapper', name: 'modelmapper', version: '2.3.8'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'
compileOnly 'org.projectlombok:lombok'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'com.h2database:h2'
runtimeOnly 'com.mysql:mysql-connector-j'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'com.auth0:java-jwt:4.4.0'
implementation 'com.squareup.okhttp3:okhttp:4.10.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.10.0'
implementation 'org.springframework.boot:spring-boot-starter-mail'
implementation 'org.springframework.boot:spring-boot-starter-websocket'
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.jsoup:jsoup:1.16.2'


}

tasks.named('test') {
Expand Down Expand Up @@ -92,7 +106,27 @@ jacocoTestCoverageVerification {

test {
finalizedBy jacocoTestReport
useJUnitPlatform()
jacoco {
excludes += ["leaguehub/leaguehubbackend/config/**",
"leaguehub/leaguehubbackend/exception/**",
"leaguehub/leaguehubbackend/repository/**",
"leaguehub/leaguehubbackend/service/kakao/**",
"leaguehub/leaguehubbackend/service/s3/**"
]
}
}
jacocoTestReport {
dependsOn test
afterEvaluate {

classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: ["leaguehub/leaguehubbackend/config/**",
"leaguehub/leaguehubbackend/exception/**",
"leaguehub/leaguehubbackend/repository/**",
"leaguehub/leaguehubbackend/service/kakao/**",
"leaguehub/leaguehubbackend/service/s3/**"])
}))
}
}
1 change: 1 addition & 0 deletions lombok.config
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lombok.addLombokGeneratedAnnotation = true
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@

@SpringBootApplication
public class LeaguehubBackendApplication {

public static void main(String[] args) {
SpringApplication.run(LeaguehubBackendApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package leaguehub.leaguehubbackend.domain.channel.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.responses.ApiResponses;
import jakarta.validation.Valid;
import leaguehub.leaguehubbackend.domain.channel.dto.ChannelBoardDto;
import leaguehub.leaguehubbackend.domain.channel.dto.ChannelBoardIndexListDto;
import leaguehub.leaguehubbackend.domain.channel.dto.ChannelBoardInfoDto;
import leaguehub.leaguehubbackend.domain.channel.dto.ChannelBoardLoadDto;
import leaguehub.leaguehubbackend.domain.channel.service.ChannelBoardService;
import leaguehub.leaguehubbackend.global.exception.global.ExceptionResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import static org.springframework.http.HttpStatus.OK;

@Slf4j
@RestController
@RequestMapping("/api")
@RequiredArgsConstructor
public class ChannelBoardController {

private final ChannelBoardService channelBoardService;

@Operation(summary = "채널 보드 만들기")
@Parameter(name = "channelLink", description = "해당 채널의 링크", example = "42aa1b11ab88")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ChannelBoardLoadDto.class))),
@ApiResponse(responseCode = "400", description = "채널 링크가 올바르지 않음, 관리자 권한 없음", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@PostMapping("/channel/{channelLink}/new")
public ResponseEntity createChannelBoard(@PathVariable("channelLink") String channelLink,
@RequestBody @Valid ChannelBoardDto request,
BindingResult bindingResult) {
ChannelBoardLoadDto channelBoardLoadDto = channelBoardService.createChannelBoard(channelLink, request);

return new ResponseEntity(channelBoardLoadDto, OK);
}

@Operation(summary = "채널 보드 업데이트")
@Parameters(value = {
@Parameter(name = "channelLink", description = "해당 채널의 링크", example = "42aa1b11ab88"),
@Parameter(name = "boardId", description = "게시판 고유 Id", example = "0, 1, 2")
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200"),
@ApiResponse(responseCode = "400", description = "채널 링크가 올바르지 않음, 관리자 권한 없음", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@PostMapping("/channel/{channelLink}/{boardId}")
public ResponseEntity updateChannelBoard(@PathVariable("channelLink") String channelLink,
@PathVariable("boardId") Long boardId,
@RequestBody ChannelBoardDto channelBoardDto) {
channelBoardService.updateChannelBoard(channelLink, boardId, channelBoardDto);

return new ResponseEntity("Board successfully updated", OK);
}

@Operation(summary = "채널 보드 삭제")
@Parameters(value = {
@Parameter(name = "channelLink", description = "해당 채널의 링크", example = "42aa1b11ab88"),
@Parameter(name = "boardId", description = "게시판 고유 Id", example = "0, 1, 2")
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200"),
@ApiResponse(responseCode = "400", description = "채널 링크가 올바르지 않음, 관리자 권한 없음", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@DeleteMapping("/channel/{channelLink}/{boardId}")
public ResponseEntity deleteChannelBoard(@PathVariable("channelLink") String channelLink,
@PathVariable("boardId") Long boardId) {

channelBoardService.deleteChannelBoard(channelLink, boardId);

return new ResponseEntity("Board successfully deleted", OK);
}

@Operation(summary = "채널 보드 가져오기 - 단일 채널 보드 읽기")
@Parameters(value = {
@Parameter(name = "channelLink", description = "해당 채널의 링크", example = "42aa1b11ab88"),
@Parameter(name = "boardId", description = "게시판 고유 Id", example = "0, 1, 2")
})
@ApiResponses(value = {
@ApiResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ChannelBoardDto.class))),
@ApiResponse(responseCode = "400", description = "채널 링크가 올바르지 않음", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@GetMapping("/channel/{channelLink}/{boardId}")
public ResponseEntity getChannelBoard(@PathVariable("channelLink") String channelLink,
@PathVariable("boardId") Long boardId) {
ChannelBoardDto channelBoardDto = channelBoardService.getChannelBoard(channelLink, boardId);

return new ResponseEntity(channelBoardDto, OK);
}

@Operation(summary = "채널 보드 인덱스 업데이트 - 채널 보드 인덱스 커스텀")
@Parameter(name = "channelLink", description = "해당 채널의 링크", example = "42aa1b11ab88")
@ApiResponses(value = {
@ApiResponse(responseCode = "200"),
@ApiResponse(responseCode = "400", description = "채널 링크가 올바르지 않음, 권한x", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@PostMapping("/channel/{channelLink}/order")
public ResponseEntity updateChannelBoardIndex(@PathVariable("channelLink") String channelLink,
@RequestBody @Valid ChannelBoardIndexListDto channelBoardIndexListDto) {
channelBoardService.updateChannelBoardIndex(channelLink, channelBoardIndexListDto.getChannelBoardLoadDtoList());

return new ResponseEntity("BoardIndex successfully updated", OK);
}

@Operation(summary = "채널 보드 가져오기 - 채널 로드시 현재 라운드와 제목과 보드ID 가져오기 리스트로 반환")
@Parameter(name = "channelLink", description = "해당 채널의 링크", example = "42aa1b11ab88")
@ApiResponses(value = {
@ApiResponse(responseCode = "200", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ChannelBoardInfoDto.class))),
@ApiResponse(responseCode = "400", description = "채널 링크가 올바르지 않음", content = @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)))
})
@GetMapping("/channel/{channelLink}/boards")
public ResponseEntity loadChannelBoards(@PathVariable("channelLink") String channelLink) {

ChannelBoardInfoDto channelBoardLoadDtoList = channelBoardService.loadChannelBoards(channelLink);

return new ResponseEntity(channelBoardLoadDtoList, OK);
}
}
Loading

0 comments on commit 96600c4

Please sign in to comment.