From 697e49e95b8d5e0014b8d4a82882d5a995fd648b Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 14:56:49 +0900 Subject: [PATCH 01/24] Update PostController.java --- .../cnu/devlog_springboot/controller/PostController.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/com/cnu/devlog_springboot/controller/PostController.java b/src/main/java/com/com/cnu/devlog_springboot/controller/PostController.java index 7d6847f..aeb2c9c 100644 --- a/src/main/java/com/com/cnu/devlog_springboot/controller/PostController.java +++ b/src/main/java/com/com/cnu/devlog_springboot/controller/PostController.java @@ -3,6 +3,8 @@ import com.com.cnu.devlog_springboot.model.Post; import com.com.cnu.devlog_springboot.model.request.PostRequest; import com.com.cnu.devlog_springboot.service.PostService; +import com.com.cnu.devlog_springboot.type.Tag; +import io.micrometer.common.lang.Nullable; import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; @@ -17,8 +19,8 @@ public class PostController { // GET /posts @GetMapping - public ResponseEntity> getPosts() { - return ResponseEntity.ok(postService.getPosts()); + public ResponseEntity> getPosts(@RequestParam @Nullable Tag tag) { + return ResponseEntity.ok(postService.getPosts(tag)); } // GET /posts/{postId} From e231b09ee6fd49691046e79871cd5ce8518c3445 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 14:57:43 +0900 Subject: [PATCH 02/24] Create ProjectController.java --- .../controller/ProjectController.java | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/controller/ProjectController.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/controller/ProjectController.java b/src/main/java/com/com/cnu/devlog_springboot/controller/ProjectController.java new file mode 100644 index 0000000..29cddde --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/controller/ProjectController.java @@ -0,0 +1,52 @@ +package com.com.cnu.devlog_springboot.controller; + +import com.com.cnu.devlog_springboot.model.Project; +import com.com.cnu.devlog_springboot.model.request.ProjectRequest; +import com.com.cnu.devlog_springboot.service.ProjectService; +import java.util.List; +import lombok.AllArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/projects") +@AllArgsConstructor +public class ProjectController { + + private final ProjectService projectService; + + @GetMapping + public ResponseEntity> getProjects() { + return ResponseEntity.ok(projectService.getProjects()); + } + + @GetMapping("{projectId}") + public ResponseEntity getProject(@PathVariable Integer projectId) { + return ResponseEntity.ok(projectService.getProject(projectId)); + } + + @PostMapping + public ResponseEntity createProject(@RequestBody ProjectRequest projectRequest) { + return ResponseEntity.ok(projectService.createProject(projectRequest)); + } + + @PostMapping("{projectId}") + public ResponseEntity updateProject( + @PathVariable Integer projectId, + @RequestBody ProjectRequest projectRequest + ) { + return ResponseEntity.ok(projectService.updateProject(projectId, projectRequest)); + } + + @DeleteMapping("{projectId}") + public ResponseEntity deleteProject(@PathVariable Integer projectId) { + projectService.deleteProject(projectId); + return ResponseEntity.noContent().build(); + } +} From 3c27f1e5691b933876ab73fe91b69a1976a1d601 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 14:58:46 +0900 Subject: [PATCH 03/24] Create DevlogException.java --- .../devlog_springboot/exception/DevlogException.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/exception/DevlogException.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/exception/DevlogException.java b/src/main/java/com/com/cnu/devlog_springboot/exception/DevlogException.java new file mode 100644 index 0000000..9da0b4e --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/exception/DevlogException.java @@ -0,0 +1,11 @@ +package com.com.cnu.devlog_springboot.exception; + +import com.com.cnu.devlog_springboot.type.ErrorCode; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class DevlogException extends RuntimeException { + private final ErrorCode errorCode; +} From 8114f05c72b1ea95a24be6673ce5c9f9abc37c1d Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 14:59:29 +0900 Subject: [PATCH 04/24] Create GlobalExceptionHandler.java --- .../exception/GlobalExceptionHandler.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/exception/GlobalExceptionHandler.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/exception/GlobalExceptionHandler.java b/src/main/java/com/com/cnu/devlog_springboot/exception/GlobalExceptionHandler.java new file mode 100644 index 0000000..da473d9 --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/exception/GlobalExceptionHandler.java @@ -0,0 +1,27 @@ +package com.com.cnu.devlog_springboot.exception; + +import com.com.cnu.devlog_springboot.model.response.ErrorResponse; +import jakarta.servlet.http.HttpServletRequest; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; + +@ControllerAdvice +public class GlobalExceptionHandler { + + @ExceptionHandler(DevlogException.class) + public ResponseEntity handlerDevlogException( + HttpServletRequest request, DevlogException e + ) { + return ResponseEntity.status(e.getErrorCode().getHttpStatus()) + .body( + new ErrorResponse( + e.getErrorCode().getDescription(), + e.getErrorCode().getHttpStatus().value(), + e.getErrorCode().getErrorCode(), + request.getRequestURI() + ) + ); + + } +} From 2955d40021b98ecb192da4824d54c43764e4661f Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:00:03 +0900 Subject: [PATCH 05/24] Update Project.java --- src/main/java/com/com/cnu/devlog_springboot/model/Project.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/com/cnu/devlog_springboot/model/Project.java b/src/main/java/com/com/cnu/devlog_springboot/model/Project.java index 29d0b72..c7032a9 100644 --- a/src/main/java/com/com/cnu/devlog_springboot/model/Project.java +++ b/src/main/java/com/com/cnu/devlog_springboot/model/Project.java @@ -1,5 +1,6 @@ package com.com.cnu.devlog_springboot.model; +import com.com.cnu.devlog_springboot.model.request.ProjectRequest; import jakarta.persistence.Entity; import jakarta.persistence.GeneratedValue; import jakarta.persistence.GenerationType; From e4fa19ed2d94a68c60cfc9521f95a400b9dd02da Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:01:00 +0900 Subject: [PATCH 06/24] Create ErrorResponse.java --- .../devlog_springboot/model/response/ErrorResponse.java | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/model/response/ErrorResponse.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/model/response/ErrorResponse.java b/src/main/java/com/com/cnu/devlog_springboot/model/response/ErrorResponse.java new file mode 100644 index 0000000..c102932 --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/model/response/ErrorResponse.java @@ -0,0 +1,9 @@ +package com.com.cnu.devlog_springboot.model.response; + +public record ErrorResponse( + String title, + Integer status, + Integer code, + String instance +) { +} From 655a97fb6c07c1ebf564d718d5aac084980e9ff2 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:02:13 +0900 Subject: [PATCH 07/24] Update PostRepository.java --- .../com/cnu/devlog_springboot/repository/PostRepository.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java b/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java index bb39395..4525744 100644 --- a/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java +++ b/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java @@ -1,6 +1,7 @@ package com.com.cnu.devlog_springboot.repository; import com.com.cnu.devlog_springboot.model.Post; +import com.com.cnu.devlog_springboot.type.Tag; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; @@ -10,4 +11,5 @@ public interface PostRepository extends JpaRepository { // List findAll(); // Optional findById(Integer postId); // void delete(Post post); + List findAllByTag(Tag tag); } From 245909b409739668af3d9b3705575e971fa8b6eb Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:03:09 +0900 Subject: [PATCH 08/24] Create ProjectRepository.java --- .../devlog_springboot/repository/ProjectRepository.java | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/repository/ProjectRepository.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/repository/ProjectRepository.java b/src/main/java/com/com/cnu/devlog_springboot/repository/ProjectRepository.java new file mode 100644 index 0000000..f9c509d --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/repository/ProjectRepository.java @@ -0,0 +1,7 @@ +package com.com.cnu.devlog_springboot.repository; + +import com.com.cnu.devlog_springboot.model.Project; +import org.springframework.data.jpa.repository.JpaRepository; + +public interface ProjectRepository extends JpaRepository { +} From 503b82b47c4ca51c67463bda14f947b48e77da63 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:05:20 +0900 Subject: [PATCH 09/24] Update PostService.java --- .../cnu/devlog_springboot/service/PostService.java | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java b/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java index 3823d7a..1eb9d4a 100644 --- a/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java +++ b/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java @@ -1,8 +1,12 @@ package com.com.cnu.devlog_springboot.service; +import com.com.cnu.devlog_springboot.exception.DevlogException; import com.com.cnu.devlog_springboot.model.Post; import com.com.cnu.devlog_springboot.model.request.PostRequest; import com.com.cnu.devlog_springboot.repository.PostRepository; +import com.com.cnu.devlog_springboot.type.ErrorCode; +import com.com.cnu.devlog_springboot.type.Tag; +import io.micrometer.common.lang.Nullable; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; @@ -13,8 +17,10 @@ public class PostService { private final PostRepository postRepository; - public List getPosts() { - return postRepository.findAll(); + public List getPosts(@Nullable Tag tag) { + if(tag != null) { + return postRepository.findAllByTag(tag); + } } public Post creatPost(PostRequest postRequest) { @@ -33,12 +39,12 @@ public Post updatePost(Integer postId, PostRequest postRequest) { post.setContents(postRequest.contents()); return postRepository.save(post); }) - .orElse(null); + .orElseThrow(() -> new DevlogException(ErrorCode.POST_NOT_FOUND)); } public Post getPost(Integer postId) { return postRepository.findById(postId) - .orElse(null); + .orElseThrow(() -> new DevlogException(ErrorCode.POST_NOT_FOUND)); } public void deletePost(Integer postId) { From 1f25a864ae169ad9dd54083e8b7fd704db62a25a Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:06:14 +0900 Subject: [PATCH 10/24] Create ProjectService.java --- .../service/ProjectService.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/service/ProjectService.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/service/ProjectService.java b/src/main/java/com/com/cnu/devlog_springboot/service/ProjectService.java new file mode 100644 index 0000000..15221de --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/service/ProjectService.java @@ -0,0 +1,56 @@ +package com.com.cnu.devlog_springboot.service; + +import com.com.cnu.devlog_springboot.exception.DevlogException; +import com.com.cnu.devlog_springboot.model.Project; +import com.com.cnu.devlog_springboot.model.request.ProjectRequest; +import com.com.cnu.devlog_springboot.repository.ProjectRepository; +import com.com.cnu.devlog_springboot.type.ErrorCode; + +import java.util.List; +import lombok.AllArgsConstructor; +import org.springframework.stereotype.Service; + +@Service +@AllArgsConstructor +public class ProjectService { + private final ProjectRepository projectRepository; + + public List getProjects() { + return projectRepository.findAll(); + } + + public Project createProject(ProjectRequest projectRequest) { + return projectRepository.save( + new Project( + null, + projectRequest.title(), + projectRequest.summary(), + projectRequest.contents(), + projectRequest.startDate(), + projectRequest.endDate() + ) + ); + } + + public Project updateProject(Integer projectId, ProjectRequest projectRequest) { + return projectRepository.findById(projectId) + .map(project -> { + project.setTitle(projectRequest.title()); + project.setContents(projectRequest.contents()); + project.setSummary(projectRequest.summary()); + project.setStartDate(projectRequest.startDate()); + project.setEndDate(projectRequest.endDate()); + return projectRepository.save(project); + }).orElseThrow(() -> new DevlogException(ErrorCode.PROJECT_NOT_FOUND)); + } + + public Project getProject(Integer projectId) { + return projectRepository.findById(projectId) + .orElseThrow(() -> new DevlogException(ErrorCode.PROJECT_NOT_FOUND)); + } + + public void deleteProject(Integer projectId) { + projectRepository.findById(projectId) + .ifPresent(projectRepository::delete); + } +} From 7327778d7301a1fb05883bf5bcb22aa14987dbd2 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:07:20 +0900 Subject: [PATCH 11/24] Create ErrorCode.java --- .../cnu/devlog_springboot/type/ErrorCode.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/com/cnu/devlog_springboot/type/ErrorCode.java diff --git a/src/main/java/com/com/cnu/devlog_springboot/type/ErrorCode.java b/src/main/java/com/com/cnu/devlog_springboot/type/ErrorCode.java new file mode 100644 index 0000000..0604e13 --- /dev/null +++ b/src/main/java/com/com/cnu/devlog_springboot/type/ErrorCode.java @@ -0,0 +1,28 @@ +package com.com.cnu.devlog_springboot.type; + +import lombok.Getter; +import org.springframework.http.HttpStatus; + +@Getter +public enum ErrorCode { + POST_NOT_FOUND( + HttpStatus.NOT_FOUND, + 4000, + "해당 게시글을 찾을 수 없습니다."), + + PROJECT_NOT_FOUND( + HttpStatus.NOT_FOUND, + 4001, + "해당 프로젝트를 찾을 수 없습니다.") + ; + + private final HttpStatus httpStatus; + private final Integer errorCode; + private final String description; + + ErrorCode(HttpStatus httpStatus, Integer errorCode, String description) { + this.httpStatus = httpStatus; + this.errorCode = errorCode; + this.description = description; + } +} From 3bf7afc5eecfd3c613c84ff55d17715e9c4f7b45 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:09:36 +0900 Subject: [PATCH 12/24] Update deployment_scp.yml --- .github/workflows/deployment_scp.yml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml index 8d91ebb..7b45b4f 100644 --- a/.github/workflows/deployment_scp.yml +++ b/.github/workflows/deployment_scp.yml @@ -21,10 +21,10 @@ jobs: steps: - name: Checkout uses: actions/checkout@v3 - - name: Set up JDK 17 + - name: Set up JDK 21 uses: actions/setup-java@v3 with: - java-version: '17' + java-version: '21' distribution: 'temurin' - name: Build with Gradle uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 @@ -46,10 +46,10 @@ jobs: - name: Send jar to remote server uses: appleboy/scp-action@master with: - host: {나의 public ip} - username: {나의 userName} + host: 58.76.20.10 + username: hongdyu source: "devlog_springboot-0.0.1-SNAPSHOT.jar" - target: "/home/{나의 userName}" + target: "/home/hongdyu" key: ${{ secrets.PRIVATE_KEY }} run-app: @@ -61,16 +61,16 @@ jobs: - name: Move deploy.sh uses: appleboy/scp-action@master with: - host: {나의 public ip} - username: {나의 userName} + host: 58.76.20.10 + username: hongdyu source: "deploy.sh" - target: "/home/{나의 userName}" + target: "/home/hongdyu" key: ${{ secrets.PRIVATE_KEY }} - name: Execute script uses: appleboy/ssh-action@master with: - username: {나의 userName} - host: {나의 public ip} + username: hongdyu + host: 58.76.20.10 key: ${{ secrets.PRIVATE_KEY }} script_stop: true - script: cd /home/{나의 userName} && chmod +x deploy.sh && ./deploy.sh + script: cd /home/hongdyu && chmod +x deploy.sh && ./deploy.sh From c16260d8c123d46b323e72d7b9489c2d28b3be9d Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:13:08 +0900 Subject: [PATCH 13/24] Update PostRepository.java --- .../com/cnu/devlog_springboot/repository/PostRepository.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java b/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java index 4525744..190a9a5 100644 --- a/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java +++ b/src/main/java/com/com/cnu/devlog_springboot/repository/PostRepository.java @@ -4,7 +4,7 @@ import com.com.cnu.devlog_springboot.type.Tag; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; - +import java.util.List; @Repository public interface PostRepository extends JpaRepository { // Post save(Post post); From a0120de008e9ea90a16e04dbc0fbc28cf1789f80 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:15:49 +0900 Subject: [PATCH 14/24] Update PostService.java --- .../java/com/com/cnu/devlog_springboot/service/PostService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java b/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java index 1eb9d4a..22ee8eb 100644 --- a/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java +++ b/src/main/java/com/com/cnu/devlog_springboot/service/PostService.java @@ -21,6 +21,7 @@ public List getPosts(@Nullable Tag tag) { if(tag != null) { return postRepository.findAllByTag(tag); } + return postRepository.findAll(); } public Post creatPost(PostRequest postRequest) { From 410baa7766078cb114fb109726ae25eecbc9cd05 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:22:55 +0900 Subject: [PATCH 15/24] Update deployment_scp.yml --- .github/workflows/deployment_scp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml index 7b45b4f..d671572 100644 --- a/.github/workflows/deployment_scp.yml +++ b/.github/workflows/deployment_scp.yml @@ -49,7 +49,7 @@ jobs: host: 58.76.20.10 username: hongdyu source: "devlog_springboot-0.0.1-SNAPSHOT.jar" - target: "/home/hongdyu" + target: "home" key: ${{ secrets.PRIVATE_KEY }} run-app: @@ -64,7 +64,7 @@ jobs: host: 58.76.20.10 username: hongdyu source: "deploy.sh" - target: "/home/hongdyu" + target: "home" key: ${{ secrets.PRIVATE_KEY }} - name: Execute script uses: appleboy/ssh-action@master @@ -73,4 +73,4 @@ jobs: host: 58.76.20.10 key: ${{ secrets.PRIVATE_KEY }} script_stop: true - script: cd /home/hongdyu && chmod +x deploy.sh && ./deploy.sh + script: cd home && chmod +x deploy.sh && ./deploy.sh From 7dd980061ae8131fd9c6a2cc6c64e8fd07b38a2c Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:38:59 +0900 Subject: [PATCH 16/24] Update deployment_scp.yml From b72c8442e9e514d2e165f88046436488aa7a0ffe Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:43:57 +0900 Subject: [PATCH 17/24] Update deployment_scp.yml --- .github/workflows/deployment_scp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml index d671572..58d00f4 100644 --- a/.github/workflows/deployment_scp.yml +++ b/.github/workflows/deployment_scp.yml @@ -46,7 +46,7 @@ jobs: - name: Send jar to remote server uses: appleboy/scp-action@master with: - host: 58.76.20.10 + host: 172.27.31.116 username: hongdyu source: "devlog_springboot-0.0.1-SNAPSHOT.jar" target: "home" @@ -61,7 +61,7 @@ jobs: - name: Move deploy.sh uses: appleboy/scp-action@master with: - host: 58.76.20.10 + host: 172.27.31.116 username: hongdyu source: "deploy.sh" target: "home" @@ -70,7 +70,7 @@ jobs: uses: appleboy/ssh-action@master with: username: hongdyu - host: 58.76.20.10 + host: 172.27.31.116 key: ${{ secrets.PRIVATE_KEY }} script_stop: true script: cd home && chmod +x deploy.sh && ./deploy.sh From e18d36339371392b05a8550a10d2a0c92dab86a9 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 15:53:16 +0900 Subject: [PATCH 18/24] Update deployment_scp.yml From 846ce9a50f9fe56770841bff8d939c650e7ebea6 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 16:05:39 +0900 Subject: [PATCH 19/24] Update deployment_scp.yml --- .github/workflows/deployment_scp.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml index 58d00f4..3702969 100644 --- a/.github/workflows/deployment_scp.yml +++ b/.github/workflows/deployment_scp.yml @@ -46,7 +46,7 @@ jobs: - name: Send jar to remote server uses: appleboy/scp-action@master with: - host: 172.27.31.116 + host: 58.76.20.10 username: hongdyu source: "devlog_springboot-0.0.1-SNAPSHOT.jar" target: "home" @@ -61,7 +61,7 @@ jobs: - name: Move deploy.sh uses: appleboy/scp-action@master with: - host: 172.27.31.116 + host: 58.76.20.10 username: hongdyu source: "deploy.sh" target: "home" @@ -70,7 +70,7 @@ jobs: uses: appleboy/ssh-action@master with: username: hongdyu - host: 172.27.31.116 + host: 58.76.20.10 key: ${{ secrets.PRIVATE_KEY }} script_stop: true - script: cd home && chmod +x deploy.sh && ./deploy.sh + script: cd /home/hongdyu && chmod +x deploy.sh && ./deploy.sh From 16845008da3a7df85737f39d4b91c2bc81f74c10 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 16:10:38 +0900 Subject: [PATCH 20/24] Update deployment_scp.yml --- .github/workflows/deployment_scp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml index 3702969..7b45b4f 100644 --- a/.github/workflows/deployment_scp.yml +++ b/.github/workflows/deployment_scp.yml @@ -49,7 +49,7 @@ jobs: host: 58.76.20.10 username: hongdyu source: "devlog_springboot-0.0.1-SNAPSHOT.jar" - target: "home" + target: "/home/hongdyu" key: ${{ secrets.PRIVATE_KEY }} run-app: @@ -64,7 +64,7 @@ jobs: host: 58.76.20.10 username: hongdyu source: "deploy.sh" - target: "home" + target: "/home/hongdyu" key: ${{ secrets.PRIVATE_KEY }} - name: Execute script uses: appleboy/ssh-action@master From 8aa8dc8df215bac041e4fe062367c52bc7c82d50 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 16:14:16 +0900 Subject: [PATCH 21/24] Create blank.yml --- .github/workflows/blank.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml new file mode 100644 index 0000000..18a6a3e --- /dev/null +++ b/.github/workflows/blank.yml @@ -0,0 +1,36 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the workflow will run +on: + # Triggers the workflow on push or pull request events but only for the "main" branch + push: + branches: [ "main" ] + pull_request: + branches: [ "main" ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v3 + + # Runs a single command using the runners shell + - name: Run a one-line script + run: echo Hello, world! + + # Runs a set of commands using the runners shell + - name: Run a multi-line script + run: | + echo Add other actions to build, + echo test, and deploy your project. From 26a758e4742849a1ca8811d3402a2c1158dd0947 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 16:18:31 +0900 Subject: [PATCH 22/24] Update PostRequest.java From 8529df545cc5b8856abaab99c4db74cf02db71cd Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 16:22:48 +0900 Subject: [PATCH 23/24] Delete .github/workflows/blank.yml --- .github/workflows/blank.yml | 36 ------------------------------------ 1 file changed, 36 deletions(-) delete mode 100644 .github/workflows/blank.yml diff --git a/.github/workflows/blank.yml b/.github/workflows/blank.yml deleted file mode 100644 index 18a6a3e..0000000 --- a/.github/workflows/blank.yml +++ /dev/null @@ -1,36 +0,0 @@ -# This is a basic workflow to help you get started with Actions - -name: CI - -# Controls when the workflow will run -on: - # Triggers the workflow on push or pull request events but only for the "main" branch - push: - branches: [ "main" ] - pull_request: - branches: [ "main" ] - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - # This workflow contains a single job called "build" - build: - # The type of runner that the job will run on - runs-on: ubuntu-latest - - # Steps represent a sequence of tasks that will be executed as part of the job - steps: - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 - - # Runs a single command using the runners shell - - name: Run a one-line script - run: echo Hello, world! - - # Runs a set of commands using the runners shell - - name: Run a multi-line script - run: | - echo Add other actions to build, - echo test, and deploy your project. From f28144ccc644811d6e51e48859acd93d0cfa4008 Mon Sep 17 00:00:00 2001 From: hongdyu01 <144324356+hongdyu01@users.noreply.github.com> Date: Mon, 6 May 2024 16:22:56 +0900 Subject: [PATCH 24/24] Delete .github/workflows/deployment_scp.yml --- .github/workflows/deployment_scp.yml | 76 ---------------------------- 1 file changed, 76 deletions(-) delete mode 100644 .github/workflows/deployment_scp.yml diff --git a/.github/workflows/deployment_scp.yml b/.github/workflows/deployment_scp.yml deleted file mode 100644 index 7b45b4f..0000000 --- a/.github/workflows/deployment_scp.yml +++ /dev/null @@ -1,76 +0,0 @@ -# This workflow uses actions that are not certified by GitHub. -# They are provided by a third-party and are governed by -# separate terms of service, privacy policy, and support -# documentation. -# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle - -name: Deployment - -on: - workflow_dispatch: - push: - branches: [ "main" ] - -permissions: - contents: read - -jobs: - build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up JDK 21 - uses: actions/setup-java@v3 - with: - java-version: '21' - distribution: 'temurin' - - name: Build with Gradle - uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1 - with: - arguments: build - - uses: actions/upload-artifact@v3 - with: - name: jar - path: build/libs - - send-jar: - needs: build - runs-on: ubuntu-latest - steps: - - name: Download jar - uses: actions/download-artifact@v3 - with: - name: jar - - name: Send jar to remote server - uses: appleboy/scp-action@master - with: - host: 58.76.20.10 - username: hongdyu - source: "devlog_springboot-0.0.1-SNAPSHOT.jar" - target: "/home/hongdyu" - key: ${{ secrets.PRIVATE_KEY }} - - run-app: - needs: send-jar - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Move deploy.sh - uses: appleboy/scp-action@master - with: - host: 58.76.20.10 - username: hongdyu - source: "deploy.sh" - target: "/home/hongdyu" - key: ${{ secrets.PRIVATE_KEY }} - - name: Execute script - uses: appleboy/ssh-action@master - with: - username: hongdyu - host: 58.76.20.10 - key: ${{ secrets.PRIVATE_KEY }} - script_stop: true - script: cd /home/hongdyu && chmod +x deploy.sh && ./deploy.sh