Skip to content

Commit

Permalink
Merge pull request #209 from TrandPick/development
Browse files Browse the repository at this point in the history
트랜드픽 ver 1.0.0 배포
  • Loading branch information
hye-0000 authored Jun 14, 2023
2 parents 3b01dd8 + be4a4af commit 37039d8
Show file tree
Hide file tree
Showing 180 changed files with 9,705 additions and 45 deletions.
104 changes: 104 additions & 0 deletions .github/workflows/work-1.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: 'work-1'
on:
push:
paths:
- '.github/workflows/**'
- 'src/**'
- 'build.gradle'
- 'Dockerfile'
- 'readme.md'
branches:
- 'main'
jobs:
build:
name: 빌드
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: application-secret.yml 생성
env:
ACTIONS_STEP_DEBUG: true
APPLICATION_SECRET: ${{ secrets.APPLICATION_SECRET_YML }}
run: echo "$APPLICATION_SECRET" > src/main/resources/application-secret.yml
- name: jdk 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: gradlew 실행 권한 부여
run: chmod +x gradlew
- name: gradle 테스트
run: ./gradlew test --no-daemon
- name: gradle 빌드
run: ./gradlew build -x test --no-daemon
- name: build 폴더를 캐시에 저장
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: build
retention-days: 1
tag:
name: 태그 생성
needs: build
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
steps:
- uses: actions/checkout@v3
- uses: mathieudutour/[email protected]
id: tag_version
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
docker:
name: 도커 이미지 빌드와 푸시
runs-on: ubuntu-latest
needs: tag
steps:
- uses: actions/checkout@v3
- name: build 가져오기
uses: actions/download-artifact@v3
with:
name: build-artifact
path: build
- name: Docker Buildx 설치
uses: docker/setup-buildx-action@v2
- name: ghcr.io 로그인
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
- name: 빌드 앤 푸시
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/${{ env.OWNER_LC }}/tredpick-1:${{ needs.tag.outputs.tag_name }},
ghcr.io/${{ env.OWNER_LC }}/tredpick-1:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: 쿠버네티스 배포
needs: [tag, docker]
runs-on: ubuntu-latest
steps:
- uses: azure/k8s-set-context@v2
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- run: |
kubectl set image deployment.apps/tredpick-1 tredpick-1=ghcr.io/angelsooho/tredpick-1:${{ needs.tag.outputs.tag_name }}
105 changes: 105 additions & 0 deletions .github/workflows/work-2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: 'work-2'
on:
push:
paths:
- '.github/workflows/**'
- 'src/**'
- 'build.gradle'
- 'Dockerfile'
- 'readme.md'
branches:
- 'development'
jobs:
build:
name: 빌드
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: application-secret.yml 생성
env:
ACTIONS_STEP_DEBUG: true
APPLICATION_SECRET: ${{ secrets.APPLICATION_SECRET_YML }}
run: echo "$APPLICATION_SECRET" > src/main/resources/application-secret.yml
- name: jdk 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'gradle'
- name: gradlew 실행 권한 부여
run: chmod +x gradlew
- name: gradle 테스트
run: ./gradlew test --no-daemon
- name: gradle 빌드
run: ./gradlew build -x test --no-daemon
- name: build 폴더를 캐시에 저장
uses: actions/upload-artifact@v3
with:
name: build-artifact
path: build
retention-days: 1
tag:
name: 태그 생성
needs: build
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
steps:
- uses: actions/checkout@v3
- uses: mathieudutour/[email protected]
id: tag_version
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.tag_version.outputs.new_tag }}
release_name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
docker:
name: 도커 이미지 빌드와 푸시
runs-on: ubuntu-latest
needs: tag
steps:
- uses: actions/checkout@v3
- name: build 가져오기
uses: actions/download-artifact@v3
with:
name: build-artifact
path: build
- name: Docker Buildx 설치
uses: docker/setup-buildx-action@v2
- name: ghcr.io 로그인
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: set lower case owner name
run: |
echo "OWNER_LC=${OWNER,,}" >> ${GITHUB_ENV}
env:
OWNER: '${{ github.repository_owner }}'
- name: 빌드 앤 푸시
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: |
ghcr.io/${{ env.OWNER_LC }}/trendpick-1:${{ needs.tag.outputs.tag_name }},
ghcr.io/${{ env.OWNER_LC }}/trendpick-1:latest
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
name: 쿠버네티스 배포
needs: [tag, docker]
runs-on: ubuntu-latest
steps:
- uses: azure/k8s-set-context@v2
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- run: |
kubectl set image deployment.apps/trendpick-1 trendpick-1=ghcr.io/trandpick/trendpick-1:${{ needs.tag.outputs.tag_name }}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ out/
.vscode/

### secret yml ###
src/main/resources/application-secret.yml
src/main/resources/application-secret.yml

### generated ###
src/main/generated
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM openjdk:17-jdk-alpine
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} app.jar
EXPOSE 8080
ENTRYPOINT ["java","-jar","-Dspring.profiles.active=prod","/app.jar"]
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
TrendPick
프로젝트 트렌드픽입니다.
프로젝트 트렌드픽입니다.
test 입니다.
test 입니다.
안녕하세요. 배포환경입니다.
25 changes: 18 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.1.0'
id 'org.springframework.boot' version '3.0.7'
id 'io.spring.dependency-management' version '1.1.0'
}

Expand All @@ -25,26 +25,31 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.jetbrains:annotations:24.0.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'org.springframework.boot:spring-boot-starter-actuator'

// log
implementation 'com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.8'

// thymeleaf
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
implementation group: 'com.github.zhanhb', name: 'thymeleaf-layout-dialect', version: '3.2.0'

// lombok
annotationProcessor 'org.projectlombok:lombok'
compileOnly 'org.projectlombok:lombok'

// spring security
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-hibernate5'
implementation 'org.thymeleaf.extras:thymeleaf-extras-springsecurity6'
testImplementation 'org.springframework.security:spring-security-test'

// 카카오 로그인, 구글 로그인, 네이버 로그인
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'

// db
runtimeOnly 'com.h2database:h2'
runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
runtimeOnly 'com.mysql:mysql-connector-j'

// test
testImplementation 'org.springframework.boot:spring-boot-starter-test'
Expand All @@ -56,11 +61,17 @@ dependencies {
annotationProcessor "jakarta.annotation:jakarta.annotation-api"
annotationProcessor "jakarta.persistence:jakarta.persistence-api"

// cache
implementation 'org.springframework.boot:spring-boot-starter-cache'

// swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.0.2'

// https://mvnrepository.com/artifact/com.amazonaws/aws-java-sdk-s3
implementation group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.12.282'

//cache & redis
implementation 'org.springframework.boot:spring-boot-starter-cache'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.session:spring-session-core'
implementation 'org.springframework.session:spring-session-data-redis'
}

tasks.named('test') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.scheduling.annotation.EnableScheduling;

@EnableCaching
@EnableScheduling
@EnableJpaAuditing
@SpringBootApplication
public class TrendPickProApplication {

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

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package project.trendpick_pro.domain.answer.controller;

import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import project.trendpick_pro.domain.answer.entity.dto.request.AnswerRequest;
import project.trendpick_pro.domain.answer.entity.dto.response.AnswerResponse;
import project.trendpick_pro.domain.answer.entity.form.AnswerForm;
import project.trendpick_pro.domain.answer.service.AnswerService;
import project.trendpick_pro.domain.common.base.rq.Rq;
import project.trendpick_pro.domain.member.entity.Member;

@Controller
@RequiredArgsConstructor
@RequestMapping("/trendpick/customerservice/answers")
public class AnswerController {
private final AnswerService answerService;
private final Rq rq;

@PreAuthorize("isAuthenticated()")
@PostMapping("register/{askId}")
public String register(@PathVariable Long askId, @Valid AnswerForm answerForm){
rq.CheckAdmin().get();
answerService.register(askId, answerForm);

return "redirect:/trendpick/customerservice/asks/{askId}".formatted(askId);
}
@PreAuthorize("isAuthenticated()")
@PostMapping("/delete/{answerId}")
public String deleteAnswer(@PathVariable Long answerId){
rq.CheckAdmin().get();
AnswerResponse answerResponse = answerService.delete(answerId);

return "redirect:/trendpick/customerservice/asks/%s".formatted(answerResponse.getAskId());
}

@PreAuthorize("isAuthenticated()")
@PostMapping("/moidfy/{answerId}")
public String modifyAnswer(@PathVariable Long answerId, @Valid AnswerForm answerForm){
rq.CheckAdmin().get();
AnswerResponse answerResponse = answerService.modify(answerId, answerForm);
return "redirect:/trendpick/customerservice/asks/%s".formatted(answerResponse.getAskId());
}
}
Loading

0 comments on commit 37039d8

Please sign in to comment.