Skip to content

Commit

Permalink
Chore : CI/CD ๊ตฌ์„ฑ (#6)
Browse files Browse the repository at this point in the history
* [fix] git commit history ๊น”๋”ํ•˜๊ฒŒ ์ˆ˜์ • - project setting branch re-merge (#4)

* Docs: add README.md

* Feat: ํ”„๋กœํŒŒ์ผ ์„ค์ • ์ถ”๊ฐ€

* Feat: ํ…Œ์ŠคํŠธ ์šฉ User Controller ์ถ”๊ฐ€

---------

Co-authored-by: Kjiw0n <[email protected]>

* Chore : Create gradle.yml for github action

Feat:CI Test

Feat:CI Test

firsy_commit

Create gradle.yml

* Chore : make deploy job in gradle.yml

Feat : Update gradle.yml

Feat : Update gradle.yml

Feat: CI/CD TEST

Feat: CI/CD TEST

Feat : Update gradle.yml

CD ๊ตฌ์ถ•์„ ์œ„ํ•œ ํŒŒ์ผ ์ˆ˜์ •

* Chore : build/deploy trouble shooting in gradle.yml

Chore : CI/CD Test

Chore : CI/CD TEST

Chore : CI/CD TEST gradle.yml๋‚ด์šฉ ๋ณต๊ตฌ

Chore : Update gradle.yml

gradle.yml ์˜ค๋ฅ˜์ˆ˜์ •์„ ์œ„ํ•ด ํŒŒ์ผ ์ˆ˜์ •

Chore : Update gradle.yml

keyscan์—์„œ ์‚ฌ์šฉํ•˜๋Š” DNS์ฃผ์†Œ ๋ณ€๊ฒฝ

Chore : Update gradle.yml

jar ์˜ค๋ฅ˜ํ•ด๊ฒฐ์œ„ํ•ด ์ˆ˜์ • ์‹œ๋„

Chore : Update build.gradle

jar ์ƒ์„ฑ๊ด€๋ จ ์ฝ”๋“œ ์ˆ˜์ •

Chore : Update build.gradle

Chore : Update gradle.yml

๋กœ๊ทธ ์ถ”๊ฐ€

Chore : Update build.gradle

jar ์ƒ์„ฑ ๊ฒฝ๋กœ ์„ค์ •

Feat:CI Test2

Feat:CI Test jdk11->jdk17

Feat:CI Test jdk11->jdk17

* Chore : Change target branch into CHAT-63

Chore : CI/CD TEST

Chore : Update gradle.yml

์ž‘์—…๋ธŒ๋ Œ์น˜์—์„œ ์ž‘์—… ์žฌ์‹œ์ž‘

Chore : Update build.gradle

์˜์กด์„ฑ ๋ฌธ์ œ ํ•ด๊ฒฐ

Chore : Update build.gradle

ํŒŒ์ผ ์ˆ˜์ •

Chore : Update gradle.yml

jar ๊ฒฝ๋กœ ์ƒ์„ธ์ง€์ •

Chore : Update build.gradle

์ž๋ฐ” ๋ฒ„์ „ ์ˆ˜์ •ํ›„ ํ…Œ์ŠคํŠธ

Chore : Update gradle.yml

๋กœ๊ทธ์ˆ˜์ •

Chore : Update gradle.yml

๋นŒ๋“œ๊ด€๋ จ๋ช…๋ น์–ด ์ˆ˜์ •

Chore : Update build.gradle

bootJar ์ž‘์—… ํ™œ์„ฑํ™”

* Chore : build ํŒŒ์ผ ์—…๋กœ๋“œ ํ…Œ์ŠคํŠธ

build ํŒŒ์ผ ์—…๋กœ๋“œ ํ…Œ์ŠคํŠธ

Chore : Update gradle.yml

๋นŒ๋“œ ๋ถ€๋ถ„ ๋กœ๊ทธ ์ถ”๊ฐ€

Chore : Update gradle.yml

jar ํŒŒ์ผ ๊ฒฝ๋กœ ์ˆ˜์ •

Chore : Update gradle.yml

๋ฌธ๋ฒ• ์˜ค๋ฅ˜ ์ˆ˜์ •

Chore : Update gradle.yml

Check deploy script exists ์ถ”๊ฐ€

Chore : deploy.sh Upload

ํŒŒ์ผ ์—…๋กœ๋“œ

Chore : Update gradle.yml

ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ์„ค์ •

Chore : Update deploy.sh

ํ™˜๊ฒฝ๋ณ€์ˆ˜ ๋ถˆ๋Ÿฌ์˜ค๊ธฐ๋กœ ๋ณ€๊ฒฝ

Chore : Update deploy.sh

ํŒŒ์ผ๊ฒฝ๋กœ ์ˆ˜์ •

Chore : Update deploy.sh

ํ‚ค๊ฐ’  ์ฐธ์กฐํ•˜๋Š” ๋ฐฉ์‹ ๋ณ€๊ฒฝ

Chore : Update deploy.sh

TARGET_DIR ๋ณ€๊ฒฝ

Chore : Update deploy.sh

์˜ค๋ฅ˜ ๋ถ„์„์„ ์œ„ํ•ด ๋กœ๊ทธ ์ถ”๊ฐ€

Chore : Update gradle.yml

ํ™˜๊ฒฝ๋ณ€์ˆ˜ ์„ค์ • ์ˆœ์„œ ๋ณ€๊ฒฝ

Chore : Update gradle.yml

Chore : Update gradle.yml

Chore : Update gradle.yml

์ž‘์—… ๋ถ„๋ฆฌ

Chore : Update deploy.sh

๋ฌธ๋ฒ• ๋ณ€๊ฒฝ

Chore : CI/CD TEST

* Chore : add Docker

Chore : Docker add

Chore : Update gradle.yml

๋„์ปค ๋นŒ๋“œ๊ณผ์ •์— ์ถ”๊ฐ€ ํ…Œ์ŠคํŠธ

Chore : Update gradle.yml

์˜ค๋ฅ˜ ์ˆ˜์ •

Chore : Update gradle.yml

Chore : Update gradle.yml

๋„์ปค ์ด๋ฉ”์ผ ์‚ฌ์šฉ์ž ์ด๋ฆ„์œผ๋กœ ๋ณ€๊ฒฝ

Chore : Update gradle.yml

Docker ์ด๋ฏธ์ง€ ํƒœ๊ทธ ์ผ๊ด€์„ฑ

Chore : Update gradle.yml

์‹œํฌ๋ฆฟ๊ฐ’์ œ๊ณต

Chore : Update gradle.yml

์ž‘์—…์ˆœ์„œ ๋ณ€๊ฒฝ

Chore : Update gradle.yml

์Šคํฌ๋ฆฝํŠธ๋‚ด์— source ~/.bash_profile ์ถ”๊ฐ€

Chore : Update gradle.yml

Chore : Update gradle.yml

Chore : Update gradle.yml

fix : remove plain jar file, add user.html

resolve "no main manifest attribute" error

fix : fix jar file name in JAR_PATH in Dockerfile

fix : fix about jar in gradle&docker

fix :

fix :

fix : github actions

fix : add sudo

fix : edit scrtips

fix : RestController into Controller

* Chore : PR merge ์ด์ „ target branch๋ฅผ develop์œผ๋กœ ๋ณ€๊ฒฝ

* Chore : GitHub Secret ์ด๋ฆ„ ๋ณ€๊ฒฝ

---------

Co-authored-by: Kjiw0n <[email protected]>
Co-authored-by: Mouon <[email protected]>
Co-authored-by: Mouon <[email protected]>
  • Loading branch information
4 people authored Jan 3, 2024
1 parent 720091c commit 2454d58
Show file tree
Hide file tree
Showing 41 changed files with 1,112 additions and 1 deletion.
65 changes: 65 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
name: Java CI/CD with Gradle

on:
push:
branches: [ "develop" ]
pull_request:
branches: [ "develop" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build with Gradle
run: ./gradlew --warning-mode all build -i

docker-build:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Grant execute permisson for gradlew
run: chmod +x gradlew

- name: Build with Gradle (without Test)
run: ./gradlew clean build -x test --stacktrace

- name: Docker Hub build & push
run: |
docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PWD }}
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }} .
docker images
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
- name: deploy
uses: appleboy/ssh-action@master
with:
username: ec2-user
host: ${{ secrets.WAS_HOST }}
key: ${{ secrets.WAS_PRIVATE_KEY }}
port: ${{ secrets.WAS_PORT }}
script: |
sudo docker ps
sudo docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.DOCKER_HUB_REPO_NAME }}
sudo docker image prune -f
Binary file added .gradle/.DS_Store
Binary file not shown.
Binary file added .gradle/8.5/checksums/checksums.lock
Binary file not shown.
Binary file added .gradle/8.5/checksums/md5-checksums.bin
Binary file not shown.
Binary file added .gradle/8.5/checksums/sha1-checksums.bin
Binary file not shown.
Binary file not shown.
Empty file.
Binary file added .gradle/8.5/fileChanges/last-build.bin
Binary file not shown.
Binary file added .gradle/8.5/fileHashes/fileHashes.lock
Binary file not shown.
Empty file added .gradle/8.5/gc.properties
Empty file.
Binary file added .gradle/buildOutputCleanup/buildOutputCleanup.lock
Binary file not shown.
2 changes: 2 additions & 0 deletions .gradle/buildOutputCleanup/cache.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#Sat Dec 30 21:59:13 KST 2023
gradle.version=8.5
Empty file added .gradle/vcs-1/gc.properties
Empty file.
111 changes: 111 additions & 0 deletions .gradle/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: Java CI with Gradle

on:
push:
branches: [ "CHAT-63-DevOps-ToolChain" ]
pull_request:
branches: [ "CHAT-63-DevOps-ToolChain" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Build with Gradle
run: ./gradlew --warning-mode all build -i


- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Docker
uses: docker/setup-docker@v2
with:
docker-version: '20.10.7' # Specify the desired Docker version

- name: Docker Login
run: docker login -u [email protected] -p ${{ secrets.DOCKER_PWD }}

- name: Build Docker Image
run: |
docker build -t [email protected]/chatdiary-image .
docker images
- name: Push Docker Image
run: docker push [email protected]/chatdiary-image

deploy:
runs-on: ubuntu-latest
needs: docker-build
steps:
- name: Checkout repository
uses: actions/checkout@v3 # Checkout ์•ก์…˜ ๋ฒ„์ „์„ v3์œผ๋กœ ์ผ์น˜

- name: Set up SSH
run: |
mkdir -p ~/.ssh
echo "${{ secrets.PRIVATE_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.HOST }} >> ~/.ssh/known_hosts
- name: Check if JAR file exists
run: |
if [ -f "./build/libs/chatdiary-0.0.1-SNAPSHOT-plain.jar" ]; then
echo "JAR file exists"
else
echo "JAR file does not exist"
fi
- name: Copy jar file to remote
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST }}
key: ${{ secrets.PRIVATE_KEY }}
source: "./build/libs/chatdiary-0.0.1-SNAPSHOT-plain.jar"
target: "/home/ec2-user/cicd"

- name: Check deploy script exists
run: |
if [ -f deploy.sh ]; then
echo "deploy.sh exists"
else
echo "deploy.sh does not exist"
exit 1
fi
- name: Copy deploy script file to remote
uses: appleboy/scp-action@master
with:
username: ec2-user
host: ${{ secrets.HOST }}
key: ${{ secrets.PRIVATE_KEY }}
source: "deploy.sh"
target: "/home/ec2-user/cicd"

- name: Execute deploy script
env:
DEPLOY_SERVER: ${{ secrets.HOST }}
DEPLOY_USER: ${{ secrets.USER }}
DEPLOY_KEY: ${{ secrets.PRIVATE_KEY }}
DEPLOY_TARGET_DIR: /home/ec2-user/app

uses: appleboy/ssh-action@master
with:
username: ec2-user
host: ${{ secrets.HOST }}
key: ${{ secrets.PRIVATE_KEY }}
script: |
chmod +x /home/ec2-user/cicd/deploy.sh
sh /home/ec2-user/cicd/deploy.sh
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM openjdk:17-alpine
ARG JAR_PATH=/build/libs/*.jar
COPY ${JAR_PATH} /home/server.jar
ENTRYPOINT ["java","-jar","/home/server.jar"]
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ dependencies {
tasks.named('test') {
useJUnitPlatform()
}

jar {
enabled = false
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="x-ua-compatible" content="IE=edge"/>
<title>Test results - ChatdiaryApplicationTests</title>
<link href="../css/base-style.css" rel="stylesheet" type="text/css"/>
<link href="../css/style.css" rel="stylesheet" type="text/css"/>
<script src="../js/report.js" type="text/javascript"></script>
</head>
<body>
<div id="content">
<h1>ChatdiaryApplicationTests</h1>
<div class="breadcrumbs">
<a href="../index.html">all</a> &gt;
<a href="../packages/com.kuit.chatdiary.html">com.kuit.chatdiary</a> &gt; ChatdiaryApplicationTests</div>
<div id="summary">
<table>
<tr>
<td>
<div class="summaryGroup">
<table>
<tr>
<td>
<div class="infoBox" id="tests">
<div class="counter">1</div>
<p>tests</p>
</div>
</td>
<td>
<div class="infoBox" id="failures">
<div class="counter">0</div>
<p>failures</p>
</div>
</td>
<td>
<div class="infoBox" id="ignored">
<div class="counter">0</div>
<p>ignored</p>
</div>
</td>
<td>
<div class="infoBox" id="duration">
<div class="counter">0.472s</div>
<p>duration</p>
</div>
</td>
</tr>
</table>
</div>
</td>
<td>
<div class="infoBox success" id="successRate">
<div class="percent">100%</div>
<p>successful</p>
</div>
</td>
</tr>
</table>
</div>
<div id="tabs">
<ul class="tabLinks">
<li>
<a href="#tab0">Tests</a>
</li>
<li>
<a href="#tab1">Standard output</a>
</li>
</ul>
<div id="tab0" class="tab">
<h2>Tests</h2>
<table>
<thead>
<tr>
<th>Test</th>
<th>Duration</th>
<th>Result</th>
</tr>
</thead>
<tr>
<td class="success">contextLoads()</td>
<td class="success">0.472s</td>
<td class="success">passed</td>
</tr>
</table>
</div>
<div id="tab1" class="tab">
<h2>Standard output</h2>
<span class="code">
<pre>01:03:55.732 [Test worker] INFO org.springframework.test.context.support.AnnotationConfigContextLoaderUtils -- Could not detect default configuration classes for test class [com.kuit.chatdiary.ChatdiaryApplicationTests]: ChatdiaryApplicationTests does not declare any static, non-private, non-final, nested classes annotated with @Configuration.
01:03:55.786 [Test worker] INFO org.springframework.boot.test.context.SpringBootTestContextBootstrapper -- Found @SpringBootConfiguration com.kuit.chatdiary.ChatdiaryApplication for test class com.kuit.chatdiary.ChatdiaryApplicationTests

. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.2.1)

2024-01-02T01:03:56.006+09:00 INFO 96587 --- [ Test worker] c.k.chatdiary.ChatdiaryApplicationTests : Starting ChatdiaryApplicationTests using Java 17.0.8 with PID 96587 (started by leehyunhee in /Users/leehyunhee/IdeaProjects/BE2)
2024-01-02T01:03:56.007+09:00 INFO 96587 --- [ Test worker] c.k.chatdiary.ChatdiaryApplicationTests : The following 1 profile is active: &quot;local&quot;
2024-01-02T01:03:56.600+09:00 INFO 96587 --- [ Test worker] c.k.chatdiary.ChatdiaryApplicationTests : Started ChatdiaryApplicationTests in 0.743 seconds (process running for 1.318)
</pre>
</span>
</div>
</div>
<div id="footer">
<p>
<div>
<label class="hidden" id="label-for-line-wrapping-toggle" for="line-wrapping-toggle">Wrap lines
<input id="line-wrapping-toggle" type="checkbox" autocomplete="off"/>
</label>
</div>Generated by
<a href="http://www.gradle.org">Gradle 8.5</a> at 2024. 1. 2. ์˜ค์ „ 1:03:57</p>
</div>
</div>
</body>
</html>
Loading

0 comments on commit 2454d58

Please sign in to comment.