-
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
7 changed files
with
106 additions
and
35 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 |
---|---|---|
@@ -1,41 +1,30 @@ | ||
name: Build and Push Docker Imamge | ||
name: Java CI with Gradle | ||
|
||
on: | ||
workflow_dispatch: # 수동 실행 트리거 | ||
# push: | ||
# branches: | ||
# - main | ||
workflow_dispatch: | ||
push: | ||
branches: | ||
- 'main' | ||
|
||
jobs: | ||
build-and-push: | ||
name: Build and Push Docker Image | ||
ci-pipeline: | ||
runs-on: ubuntu-latest | ||
|
||
steps: # 레포지토리 체크아웃 | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 # JDK 17 설정 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '17' | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Build with Gradle # Gradle 빌드 | ||
run: ./gradlew build -x test | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '17' | ||
|
||
- name: Set up Docker Buildx # Docker Buildx 설정 | ||
uses: docker/setup-buildx-aciton@v2 | ||
|
||
- name: Login to Docker Hub # Docker Hub 로그인 | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKER_USERNAME }} | ||
password: ${{ secrets.DOCKER_PASSWORD }} | ||
|
||
- name: Build and Push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ secrets.DOCKER_USERNAME }}/spring-app:version1 | ||
- name: Grant execute permission for Gradle Wrapper | ||
run: chmod +x ./gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
|
||
- name: Test with Gradle | ||
run: ./gradlew test |
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,14 @@ | ||
# 도커 이미지를 빌드할 때 필요한 커맨드를 가짐 | ||
|
||
# jdk17 image start | ||
FROM openjdk:17 | ||
|
||
# 인자 설정 - JAR_File | ||
ARG JAR_FILE=build/libs/*.jar | ||
|
||
# jar 파일 복제 | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# 실행 명령어 | ||
ENTRYPOINT ["java", "-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
48 changes: 48 additions & 0 deletions
48
src/main/java/com/example/apapbackend/domain/report/ReportController.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,48 @@ | ||
package com.example.apapbackend.domain.report; | ||
|
||
import io.swagger.v3.oas.annotations.Operation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.core.io.Resource; | ||
import org.springframework.core.io.ResourceLoader; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
@RequestMapping("/api/report") | ||
@RequiredArgsConstructor | ||
public class ReportController { | ||
|
||
private final ReportService reportService; | ||
private final ResourceLoader resourceLoader; | ||
|
||
@Value("classpath:static/report.pdf") | ||
private Resource resource; | ||
|
||
@GetMapping | ||
public ResponseEntity<Resource> getDailyReport() { | ||
// 리소스 로더를 사용하여 리소스를 로드합니다. | ||
org.springframework.core.io.Resource resource = resourceLoader.getResource( | ||
"classpath:static/report.pdf"); | ||
|
||
try { | ||
// 파일 다운로드를 위해 적절한 헤더를 설정합니다. | ||
return ResponseEntity.ok() | ||
.header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"2024_08_30_daily_report.pdf\"") | ||
.body(this.resource); | ||
} catch (Exception e) { | ||
// 오류 처리 | ||
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).build(); | ||
} | ||
} | ||
@Operation(summary = "주간 보고서 다운로드") | ||
public void getWeeklyOfDay( | ||
|
||
) { | ||
|
||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/java/com/example/apapbackend/domain/report/ReportService.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,20 @@ | ||
package com.example.apapbackend.domain.report; | ||
|
||
import com.example.apapbackend.domain.Info.Info; | ||
import com.example.apapbackend.domain.Info.InfoRepository; | ||
import com.example.apapbackend.domain.Info.InfoService; | ||
import java.time.LocalDate; | ||
import java.util.List; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class ReportService { | ||
|
||
private final InfoService infoService; | ||
|
||
public void getDailyReport(LocalDate localDate) { | ||
List<Info> infos = infoService.getInfos(localDate, localDate, null, null); | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.