Skip to content
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

๐Ÿ‘ท CI. CI/CD ํŒŒ์ดํ”„๋ผ์ธ ๊ตฌ์ถ• #2

Merged
merged 8 commits into from
Mar 31, 2024
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/issue-template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: issue template
about: ์ด์Šˆ ํ…œํ”Œ๋ฆฟ
title: ''
labels: ''
assignees: ''

---

# ๐Ÿ“ Preview





# โœ… Todo
- [ ]
- [ ]
- [ ]


# ๐Ÿ“Œ Remark
19 changes: 19 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
```
- commit message๊ฐ€ ์ ์ ˆํ•œ์ง€ ํ™•์ธํ•ด์ฃผ์„ธ์š”.
- ๋งˆ์ง€๋ง‰์œผ๋กœ Coding Convention์„ ์ค€์ˆ˜ํ–ˆ๋Š”์ง€ ํ™•์ธํ•ด์ฃผ์„ธ์š”.
- ์ ์ ˆํ•œ branch๋กœ ์š”์ฒญํ–ˆ๋Š”์ง€ ํ™•์ธํ•ด์ฃผ์„ธ์š”.
- Assignees, Label์„ ๋ถ™์—ฌ์ฃผ์„ธ์š”.
- ๊ฐ€๋Šฅํ•œ ์ด์Šˆ๋ฅผ Link ํ•ด์ฃผ์„ธ์š”.
- PR์ด ์Šน์ธ๋œ ๊ฒฝ์šฐ ํ•ด๋‹น ๋ธŒ๋žœ์น˜๋Š” ์‚ญ์ œ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.
```

## ๊ด€๋ จ ์ด์Šˆ
closed #

## ๋ณ€๊ฒฝ ์‚ฌํ•ญ ๋ฐ ์ด์œ 
ํ•ด๋‹น pr์—์„œ ์ž‘์—…ํ•œ ๋‚ด์—ญ์„ ์ ์–ด์ฃผ์„ธ์š”.

## PR Point
๋ณ€๊ฒฝ์‚ฌํ•ญ ๋ฐ ์ฃผ์˜ ์‚ฌํ•ญ (๋ชจ๋“ˆ ์„ค์น˜ ๋“ฑ)์„ ์ ์–ด์ฃผ์„ธ์š”.

## ๐Ÿ“ธ ScreenShot
72 changes: 72 additions & 0 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: FairyTale Dev CI/CD

on:
push:
branches: [ "dev" ]
pull_request:
branches: [ "dev" ]
workflow_dispatch:


permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest
# JDK ์„ค์ •
steps:
- name: Checkout
uses: actions/checkout@v3

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

# gradle build ์‹œ๊ฐ„ ํ–ฅ์ƒ
- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

# application.yml ํŒŒ์ผ ์ƒ์„ฑ
- name: make application.yml
run: |
mkdir -p src/main/resources
echo "$APPLICATION" > src/main/resources/application.properties
env:
APPLICATION: ${{ secrets.APPLICATION }}

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

- name: Build with Gradle
run: ./gradlew build -x test

- name: Docker build
run: |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
docker push ${{ secrets.DOCKER_USERNAME }}/fairytale:latest

- name: Deploy to dev
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ubuntu
key: ${{ secrets.PRIVATE_KEY }}
script: |
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
sudo docker stop $(docker ps -a -q)
sudo docker run -d --log-driver=syslog -p 8080:8080 -e SPRING_PROFILES_ACTIVE= ${{ secrets.DOCKER_USERNAME }}/fairytale:latest
sudo docker rm $(docker ps --filter 'status=exited' -a -q)
sudo docker image prune -a -f

3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
FROM openjdk:17
COPY ./build/libs/TBD-0.0.1-SNAPSHOT.jar fairytale.jar
ENTRYPOINT ["java", "-jar", "fairytale.jar"]
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ java {
sourceCompatibility = '17'
}

// build ์ด๋ฆ„ ๋ณ€๊ฒฝ
jar{
archiveBaseName = 'fairytale'
version = '0.0.1-SNAPSHOT'
enabled = false
}

configurations {
compileOnly {
extendsFrom annotationProcessor
Expand Down
Loading