From f464479f46f40a036cc3124264f8a59ee8293e71 Mon Sep 17 00:00:00 2001 From: yubin-im Date: Tue, 2 Jul 2024 14:39:52 +0900 Subject: [PATCH 1/2] =?UTF-8?q?build:=20=EC=9E=90=EB=8F=99=EB=B0=B0?= =?UTF-8?q?=ED=8F=AC=20=EC=8A=A4=ED=81=AC=EB=A6=BD=ED=8A=B8=20=EC=9E=91?= =?UTF-8?q?=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 58 ++++++++++++++++++++++++++++++++++++ build.gradle | 4 ++- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2f99506 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,58 @@ +name: CD with Gradle + +on: + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout source code + - uses: actions/checkout@v3 + + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'temurin' + + - name: make application yml + run: | + cd ./src/main/resources + touch ./application.yml + echo "${{ secrets.APPLICATION_YML }}" > ./application.yml + shell: bash + + - name: Build with Gradle + run: | + chmod +x ./gradlew + ./gradlew clean build -x test + + - name: Docker build & push to docker repo + run: | + docker login -u ${{ secrets.DOCKER_USERNAME_YUB }} -p ${{ secrets.DOCKER_PASSWORD_YUB }} + docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun . + docker push ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun + + - name: Deploy to server + uses: appleboy/ssh-action@master + id: deploy + with: + host: ${{ secrets.EC2_HOST }} + username: ec2-user + key: ${{ secrets.EC2_SSH_KEY }} + envs: GITHUB_SHA + script: | + sudo docker ps + sudo docker pull ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun + sudo docker stop hanafun + sudo docker rm hanafun + sudo docker run -it -d -p 8099:8080 --name hanafun ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun + sudo docker image prune -f \ No newline at end of file diff --git a/build.gradle b/build.gradle index 6b0ecc1..c140101 100644 --- a/build.gradle +++ b/build.gradle @@ -51,4 +51,6 @@ tasks.named('test') { bootJar { duplicatesStrategy = 'exclude' -} \ No newline at end of file +} + +jar { enabled = false } \ No newline at end of file From 78260af94bfa2777f78302be39b7417f181a4375 Mon Sep 17 00:00:00 2001 From: yubin-im Date: Tue, 2 Jul 2024 15:41:04 +0900 Subject: [PATCH 2/2] =?UTF-8?q?feat:=20=EA=B0=9C=EC=84=A4=20=ED=81=B4?= =?UTF-8?q?=EB=9E=98=EC=8A=A4=20=EB=AA=A9=EB=A1=9D=20userId->=20=ED=86=A0?= =?UTF-8?q?=ED=81=B0=20=EC=82=AC=EC=9A=A9=EC=9C=BC=EB=A1=9C=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/deploy.yml | 58 ------------------- .../lesson/controller/LessonController.java | 5 +- .../hanafun/lesson/service/LessonService.java | 2 +- .../service/impl/LessonServiceImpl.java | 4 +- 4 files changed, 6 insertions(+), 63 deletions(-) delete mode 100644 .github/workflows/deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 2f99506..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,58 +0,0 @@ -name: CD with Gradle - -on: - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout source code - - uses: actions/checkout@v3 - - - name: Set up JDK 17 - uses: actions/setup-java@v3 - with: - java-version: '17' - distribution: 'temurin' - - - name: make application yml - run: | - cd ./src/main/resources - touch ./application.yml - echo "${{ secrets.APPLICATION_YML }}" > ./application.yml - shell: bash - - - name: Build with Gradle - run: | - chmod +x ./gradlew - ./gradlew clean build -x test - - - name: Docker build & push to docker repo - run: | - docker login -u ${{ secrets.DOCKER_USERNAME_YUB }} -p ${{ secrets.DOCKER_PASSWORD_YUB }} - docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun . - docker push ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun - - - name: Deploy to server - uses: appleboy/ssh-action@master - id: deploy - with: - host: ${{ secrets.EC2_HOST }} - username: ec2-user - key: ${{ secrets.EC2_SSH_KEY }} - envs: GITHUB_SHA - script: | - sudo docker ps - sudo docker pull ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun - sudo docker stop hanafun - sudo docker rm hanafun - sudo docker run -it -d -p 8099:8080 --name hanafun ${{ secrets.DOCKER_USERNAME_YUB }}/hanafun - sudo docker image prune -f \ No newline at end of file diff --git a/src/main/java/com/hanaro/hanafun/lesson/controller/LessonController.java b/src/main/java/com/hanaro/hanafun/lesson/controller/LessonController.java index 1c5e59b..a707dcb 100644 --- a/src/main/java/com/hanaro/hanafun/lesson/controller/LessonController.java +++ b/src/main/java/com/hanaro/hanafun/lesson/controller/LessonController.java @@ -12,6 +12,7 @@ import com.hanaro.hanafun.lessondate.service.LessonDateService; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; +import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; @@ -27,8 +28,8 @@ public class LessonController { // 개설 클래스 관리- 개설 클래스 목록 출력 @GetMapping("/reservation/my/opened") - public ResponseEntity openedLessons(@RequestBody OpenedLessonsReqDto openedLessonsReqDto) { - List openedLessons = lessonService.openedLessons(openedLessonsReqDto); + public ResponseEntity openedLessons(@AuthenticationPrincipal Long userId) { + List openedLessons = lessonService.openedLessons(userId); return ResponseEntity.ok(new ApiResponse<>(true, "ok", openedLessons)); } diff --git a/src/main/java/com/hanaro/hanafun/lesson/service/LessonService.java b/src/main/java/com/hanaro/hanafun/lesson/service/LessonService.java index f6c297d..38d58ba 100644 --- a/src/main/java/com/hanaro/hanafun/lesson/service/LessonService.java +++ b/src/main/java/com/hanaro/hanafun/lesson/service/LessonService.java @@ -10,7 +10,7 @@ public interface LessonService { // 개설 클래스 관리- 개설 클래스 목록 출력 - List openedLessons(OpenedLessonsReqDto openedLessonsReqDto); + List openedLessons(Long userId); // 클래스 상세보기 LessonInfoResDto lessonInfo(Long lessonId); diff --git a/src/main/java/com/hanaro/hanafun/lesson/service/impl/LessonServiceImpl.java b/src/main/java/com/hanaro/hanafun/lesson/service/impl/LessonServiceImpl.java index 87a1cc6..300e735 100644 --- a/src/main/java/com/hanaro/hanafun/lesson/service/impl/LessonServiceImpl.java +++ b/src/main/java/com/hanaro/hanafun/lesson/service/impl/LessonServiceImpl.java @@ -37,8 +37,8 @@ public class LessonServiceImpl implements LessonService { // 개설 클래스 관리- 개설 클래스 목록 출력 @Transactional @Override - public List openedLessons(OpenedLessonsReqDto openedLessonsReqDto) { - HostEntity host = hostRepository.findHostEntityByUserEntity_UserId(openedLessonsReqDto.getUserId()); + public List openedLessons(Long userId) { + HostEntity host = hostRepository.findHostEntityByUserEntity_UserId(userId); List lessons = lessonRepository.findLessonEntitiesByHostEntity(host); List openedLessons = lessons.stream()