-
Notifications
You must be signed in to change notification settings - Fork 0
feat(#7): 자동 배포를 위한 CD 워크플로우 추가 #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19c0faf
a4cdd9f
b804e91
f9ae19d
8b84a03
d3932e4
d808bd6
d06e0ee
c57da15
f07c68c
461571c
47f6ed7
ea853bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| name: CD - PROD | ||
|
|
||
| on: | ||
| push: | ||
| branches: [ main ] | ||
|
|
||
| jobs: | ||
| deploy: | ||
| runs-on: ubuntu-latest | ||
|
|
||
| steps: | ||
| - uses: actions/checkout@v4 | ||
|
|
||
| - uses: actions/setup-java@v4 | ||
| with: | ||
| java-version: "21" | ||
| distribution: "temurin" | ||
|
|
||
| - uses: gradle/actions/setup-gradle@v3 | ||
|
|
||
| - name: Grant execute permission | ||
| run: chmod +x gradlew | ||
|
|
||
| - name: Build JAR | ||
| run: ./gradlew build -x test | ||
|
|
||
| - name: Docker Login | ||
| uses: docker/login-action@v3 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Build & Push | ||
| uses: docker/build-push-action@v5 | ||
| with: | ||
| context: . | ||
| push: true | ||
| tags: | | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/realmatch-backend:prod | ||
| ${{ secrets.DOCKERHUB_USERNAME }}/realmatch-backend:${{ github.sha }} | ||
|
|
||
| - name: Deploy | ||
| uses: appleboy/ssh-action@v1.0.3 | ||
| with: | ||
| host: ${{ secrets.PROD_SERVER_IP }} | ||
| username: ubuntu | ||
| key: ${{ secrets.PROD_SERVER_SSH_KEY }} | ||
| script: | | ||
| cd /home/ubuntu/realmatch | ||
| git pull origin main | ||
|
|
||
| docker compose pull | ||
| docker compose up -d | ||
|
|
||
| echo "Waiting for app to start..." | ||
| sleep 10 | ||
|
|
||
| if ! docker compose ps | grep "Up"; then | ||
| echo "❌ Container is not running" | ||
| docker compose logs | ||
| exit 1 | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ plugins { | |
| id 'java' | ||
| id 'org.springframework.boot' version '3.5.9' | ||
| id 'io.spring.dependency-management' version '1.1.7' | ||
| id 'checkstyle' | ||
| } | ||
|
|
||
| group = 'com.example' | ||
|
|
@@ -25,16 +26,55 @@ repositories { | |
| } | ||
|
|
||
| dependencies { | ||
| implementation 'org.springframework.boot:spring-boot-starter' | ||
| implementation 'org.springframework.boot:spring-boot-starter-security' | ||
| implementation 'org.springframework.boot:spring-boot-starter-data-jdbc' | ||
| implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
| implementation 'org.springframework.boot:spring-boot-starter-web' | ||
| implementation 'org.springframework.boot:spring-boot-starter-validation' | ||
| compileOnly 'org.projectlombok:lombok' | ||
| runtimeOnly 'com.mysql:mysql-connector-j' | ||
| annotationProcessor 'org.projectlombok:lombok' | ||
|
|
||
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
|
|
||
| // Test dependencies | ||
| testRuntimeOnly 'com.h2database:h2' | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
| testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
| testImplementation 'org.springframework.security:spring-security-test' | ||
| testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
|
Comment on lines
38
to
46
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| //JWT | ||
| implementation 'io.jsonwebtoken:jjwt-api:0.12.6' | ||
| implementation 'io.jsonwebtoken:jjwt-impl:0.12.6' | ||
| implementation 'io.jsonwebtoken:jjwt-jackson:0.12.6' | ||
|
|
||
| // mySQL | ||
| runtimeOnly 'com.mysql:mysql-connector-j' | ||
|
|
||
| // swagger | ||
| implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.8.9' | ||
| } | ||
|
|
||
| tasks.named('test') { | ||
| useJUnitPlatform() | ||
| } | ||
|
|
||
| tasks.withType(JavaCompile) { | ||
| options.encoding = 'UTF-8' | ||
| } | ||
|
|
||
| checkstyle { | ||
| toolVersion = '10.12.5' | ||
| configFile = file("${rootProject.projectDir}/config/checkstyle/checkstyle.xml") | ||
| maxWarnings = 0 | ||
| ignoreFailures = false | ||
| } | ||
|
|
||
| tasks.withType(Checkstyle) { | ||
| reports { | ||
| xml.required = true | ||
| html.required = true | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| package com.example.RealMatch.global.common; | ||
|
|
||
| import java.time.LocalDateTime; | ||
|
|
||
| import org.springframework.data.annotation.CreatedDate; | ||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
|
|
||
| import jakarta.persistence.Column; | ||
| import jakarta.persistence.EntityListeners; | ||
| import jakarta.persistence.MappedSuperclass; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| @Getter | ||
| @MappedSuperclass | ||
| @EntityListeners(AuditingEntityListener.class) | ||
| @NoArgsConstructor(access = lombok.AccessLevel.PROTECTED) | ||
| public abstract class BaseEntity { | ||
|
|
||
| @CreatedDate | ||
| @Column(name = "created_at", updatable = false, nullable = false) | ||
| private LocalDateTime createdAt; | ||
|
|
||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||
| package com.example.RealMatch.global.common; | ||||||||||||||||||
|
|
||||||||||||||||||
| import java.time.LocalDateTime; | ||||||||||||||||||
|
|
||||||||||||||||||
| import org.springframework.data.annotation.LastModifiedDate; | ||||||||||||||||||
| import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||||||||||||||||||
|
|
||||||||||||||||||
| import jakarta.persistence.Column; | ||||||||||||||||||
| import jakarta.persistence.EntityListeners; | ||||||||||||||||||
| import jakarta.persistence.MappedSuperclass; | ||||||||||||||||||
| import lombok.Getter; | ||||||||||||||||||
|
|
||||||||||||||||||
| @Getter | ||||||||||||||||||
| @MappedSuperclass | ||||||||||||||||||
| @EntityListeners(AuditingEntityListener.class) | ||||||||||||||||||
| public abstract class UpdateBaseEntity extends BaseEntity { | ||||||||||||||||||
|
|
||||||||||||||||||
| @LastModifiedDate | ||||||||||||||||||
| @Column(name = "updated_at") | ||||||||||||||||||
| private LocalDateTime updatedAt; | ||||||||||||||||||
|
|
||||||||||||||||||
| @Column(name = "deleted_at") | ||||||||||||||||||
| private LocalDateTime deletedAt; | ||||||||||||||||||
|
|
||||||||||||||||||
| @Column(name = "is_deleted", nullable = false) | ||||||||||||||||||
| private boolean isDeleted; | ||||||||||||||||||
|
|
||||||||||||||||||
| protected UpdateBaseEntity() { | ||||||||||||||||||
| super(); | ||||||||||||||||||
| this.isDeleted = false; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| public void softDelete(Integer deletedBy, LocalDateTime deletedAt) { | ||||||||||||||||||
| this.isDeleted = true; | ||||||||||||||||||
| this.deletedAt = deletedAt; | ||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+33
to
+36
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| public void restore() { | ||||||||||||||||||
| this.isDeleted = false; | ||||||||||||||||||
| this.deletedAt = null; | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PROD_SERVER_IP는 가비아 IP가 맞나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네네 노션에 올려주신 IP로 사용했습니다.