Skip to content

Commit 7def386

Browse files
committed
chore : cicd설정
1 parent c5b71ab commit 7def386

File tree

5 files changed

+71
-4
lines changed

5 files changed

+71
-4
lines changed

.github/workflows/deploy.yml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: Deploy
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
- feature/issue-4
8+
9+
jobs:
10+
CI-CD:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v3
14+
- name: Set up JDK 17
15+
uses: actions/setup-java@v3
16+
with:
17+
java-version: 17
18+
distribution: 'temurin'
19+
20+
- name: Grant execute permissions for gradlew
21+
run: chmod +x ./gradlew
22+
23+
- name: Verify Gradle version
24+
run: ./gradlew --version
25+
26+
# gradle build
27+
- name: Build with Gradle
28+
run: ./gradlew build -x test
29+
30+
# docker build & push to production
31+
- name: Docker build & push to prod
32+
# if: contains(github.ref, 'main')
33+
if: github.ref == 'refs/heads/feature/issue-4'
34+
run: |
35+
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
36+
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/embitips_back .
37+
docker push ${{ secrets.DOCKER_USERNAME }}/embitips_back
38+
39+
## deploy to production
40+
- name: Deploy to prod
41+
uses: appleboy/ssh-action@master
42+
id: deploy-prod
43+
# if: contains(github.ref, 'main')
44+
if: github.ref == 'refs/heads/feature/issue-4'
45+
with:
46+
host: ${{ secrets.HOST_PROD }} # EC2 퍼블릭 IPv4 DNS
47+
username: ${{ secrets.USERNAME }}
48+
key: ${{ secrets.PRIVATE_KEY }}
49+
envs: GITHUB_SHA
50+
script: |
51+
# 기존 컨테이너 중지 및 삭제
52+
sudo docker stop embitips_back || true
53+
sudo docker rm embitips_back || true
54+
sudo docker ps
55+
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/embitips_back
56+
sudo docker run -d -p 8080:8080 -e DB_URL="${{ secrets.DB_URL }}" -e DB_USERNAME="${{ secrets.DB_USERNAME }}" -e DB_PASSWORD="${{ secrets.DB_PASSWORD }}" --name embitips_back ${{ secrets.DOCKER_USERNAME }}/embitips_back
57+
sudo docker image prune -f

core/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11

22
dependencies {
33
}
4+
tasks.bootJar {
5+
enabled = false
6+
}

external/build.gradle.kts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,8 @@ dependencyManagement {
1212
imports {
1313
mavenBom("org.springframework.cloud:spring-cloud-dependencies:${property("springCloudVersion")}")
1414
}
15+
}
16+
17+
tasks.bootJar {
18+
enabled = false
1519
}

repository/build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ tasks.named("clean") {
3232
doLast {
3333
file(querydslDir).deleteRecursively()
3434
}
35+
}
36+
tasks.bootJar {
37+
enabled = false
3538
}

repository/src/main/resources/application.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11

22
spring:
33
datasource:
4-
driver-class-name: com.mysql.cj.jdbc.Driver
5-
url: "jdbc:mysql://localhost:3306/problem"
6-
username: root
7-
password: "!qotjrdyd1"
4+
url: ${DB_URL}
5+
username: ${DB_USERNAME}
6+
password: ${DB_PASSWORD}
7+
driver-class-name: com.mysql.cj.jdbc.Driver
88

99
jpa:
1010
show-sql: true

0 commit comments

Comments
 (0)