diff --git a/.dockerignore b/.dockerignore index 8893889..dd3a1b7 100644 --- a/.dockerignore +++ b/.dockerignore @@ -7,7 +7,7 @@ **/.DS_Store **/.classpath **/.dockerignore -**/.env +#**/.env **/.factorypath **/.git **/.gitignore @@ -23,8 +23,8 @@ **/*.dbmdl **/*.jfm **/charts -**/docker-compose* -**/compose.y*ml +#**/docker-compose* +#**/compose.y*ml **/Dockerfile* **/secrets.dev.yaml **/values.dev.yaml diff --git a/.github/workflows/random_reviewer/reviewer.js b/.github/workflows/random_reviewer/reviewer.js index 3cebb98..3e0a6de 100644 --- a/.github/workflows/random_reviewer/reviewer.js +++ b/.github/workflows/random_reviewer/reviewer.js @@ -17,11 +17,11 @@ function selectRandomReviewer() { ] } -async function sendDiscordMsg(reviewer) { +async function sendDiscordMsg(reviewer, title) { const webhook = process.env.DISCORD_WEBHOOK; const msg = { - content: createMsg(reviewer) + content: createMsg(reviewer, title) } await fetch(webhook, { @@ -31,15 +31,25 @@ async function sendDiscordMsg(reviewer) { }) } -function createMsg(reviewer) { - return "리뷰해주세요\n" + "* PR: " + `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${github.context.payload.pull_request.number}` - + "\n* 담당자: @" + "<@&" + member[reviewer] + ">" +function createMsg(reviewer, title) { + return title + "\n" + "* PR: " + `https://github.com/${github.context.repo.owner}/${github.context.repo.repo}/pulls/${github.context.payload.pull_request.number}` + + "\n* 담당자: " + "<@!" + member[reviewer] + ">" } async function main() { const githubClient = github.getOctokit(process.env.REVIEW_TOKEN); const reviewer = selectRandomReviewer(); + const { owner, repo } = github.context.repo; + + const pr = await githubClient.rest.pulls.get( + { + owner: owner, + repo: repo, + pull_number: github.context.payload.pull_request.number + } + ) + githubClient.rest.pulls.requestReviewers( { owner: github.context.repo.owner, @@ -51,7 +61,7 @@ async function main() { .then((res) => console.log("reviewer assign success: ", res)) .catch((err) => console.log("reviewer assign failed:", err)); - sendDiscordMsg(reviewer) + sendDiscordMsg(reviewer, pr.data.title) .then(() => console.log("message send success")) .catch(() => console.log("message send failed")); } diff --git a/build.gradle b/build.gradle index 650781e..f16a19e 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'com.diffplug.spotless' version '6.25.0' } -group = 'com.example' +group = 'com.gdgoc' version = '0.0.1-SNAPSHOT' java { @@ -27,6 +27,8 @@ repositories { dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' + implementation 'org.springframework.boot:spring-boot-starter-data-jpa' + implementation 'org.postgresql:postgresql' compileOnly 'org.projectlombok:lombok' annotationProcessor 'org.projectlombok:lombok' testImplementation 'org.springframework.boot:spring-boot-starter-test' @@ -56,3 +58,19 @@ spotless { endWithNewline() } } + +tasks.register("updateGitHooks", Copy) { + from "./scripts/pre-commit" + into ".git/hooks" + onlyIf { + System.getenv("NO_GIT_HOOKS") == "true" + } +} +tasks.register("executableGitHooks", Exec) { + commandLine "chmod", "ug+x", ".git/hooks/pre-commit" + dependsOn(updateGitHooks) + onlyIf { + System.getenv("NO_GIT_HOOKS") == "true" + } +} +compileJava.dependsOn(executableGitHooks) \ No newline at end of file diff --git a/compose.yaml b/compose.yaml index eebbc26..fd195a5 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,7 +1,38 @@ services: server: + env_file: + - ./env/server.env + - ./env/db.env + environment: + - NO_GIT_HOOKS="true" platform: linux/arm64 build: context: . ports: - - 8080:8080 \ No newline at end of file + - "8080:8080" + depends_on: + - db + + db: + env_file: + - ./env/db.env + image: postgres + restart: always + ports: + - "5432:5432" + volumes: + - data:/data/db + + pgadmin: + container_name: pgadmin + image: dpage/pgadmin4 + ports: + - "8088:80" + environment: + - PGADMIN_DEFAULT_EMAIL=gdgoc@admin.com + - PGADMIN_DEFAULT_PASSWORD=0000 + depends_on: + - db + +volumes: + data: \ No newline at end of file diff --git a/scripts/pre-commit b/scripts/pre-commit new file mode 100644 index 0000000..d78dcb7 --- /dev/null +++ b/scripts/pre-commit @@ -0,0 +1,16 @@ +#!/bin/sh + +# 변경된 파일들 이름만 추출하여 저장 +stagedFiles=$(git diff --staged --name-only) + +# SpotlessApply 실행 +echo "Running spotlessApply. Formatting code..." + +./gradlew spotlessApply + +# 변경사항이 발생한 파일들 다시 git add +for file in $stagedFiles; do + if test -f "$file"; then + git add "$file" + fi +done \ No newline at end of file diff --git a/src/main/java/com/example/study_group/StudyGroupApplication.java b/src/main/java/com/gdgoc/study_group/StudyGroupApplication.java similarity index 56% rename from src/main/java/com/example/study_group/StudyGroupApplication.java rename to src/main/java/com/gdgoc/study_group/StudyGroupApplication.java index 60c09ab..a463944 100644 --- a/src/main/java/com/example/study_group/StudyGroupApplication.java +++ b/src/main/java/com/gdgoc/study_group/StudyGroupApplication.java @@ -1,4 +1,4 @@ -package com.example.study_group; +package com.gdgoc.study_group; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @@ -6,8 +6,7 @@ @SpringBootApplication public class StudyGroupApplication { - public static void main(String[] args) { - SpringApplication.run(StudyGroupApplication.class, args); - } - + public static void main(String[] args) { + SpringApplication.run(StudyGroupApplication.class, args); + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index d1c1f24..f8dc6af 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,10 +1,13 @@ server: - port: 8080 - address: + port: ${SERVER_PORT} + address: ${SERVER_ADDRESS} spring: - application: - name: study-group + datasource: + driver-class-name: org.postgresql.Driver + url: jdbc:postgresql://${POSTGRES_URL}:${POSTGRES_PORT}/${POSTGRES_DB} + username: ${POSTGRES_USER} + password: ${POSTGRES_PASSWORD} jpa: hibernate: @@ -12,6 +15,6 @@ spring: properties: hibernate: format_sql: true - create_empty_composites: - enabled: true - show-sql: true \ No newline at end of file + dialect: org.hibernate.dialect.PostgreSQLDialect + show-sql: true + diff --git a/src/test/java/com/example/study_group/StudyGroupApplicationTests.java b/src/test/java/com/example/study_group/StudyGroupApplicationTests.java deleted file mode 100644 index 24d4a56..0000000 --- a/src/test/java/com/example/study_group/StudyGroupApplicationTests.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.example.study_group; - -import org.junit.jupiter.api.Test; -import org.springframework.boot.test.context.SpringBootTest; - -@SpringBootTest -class StudyGroupApplicationTests { - - @Test - void contextLoads() {} -}