-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/HanaPiece/hana-piece-server …
…into feat/account-auto-split
- Loading branch information
Showing
4 changed files
with
157 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: CI/CD using github actions & docker | ||
|
||
# event trigger | ||
# main 브랜치에 push가 되었을 때 실행 | ||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
CI-CD: | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
# JDK 설정 | ||
- uses: actions/checkout@v4 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
# Gradle 캐시 설정 | ||
- name: Gradle Caching | ||
uses: actions/cache@v4 | ||
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 | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
echo "spring:" >> ./application.yml | ||
echo " jpa:" >> ./application.yml | ||
echo " database: mysql" >> ./application.yml | ||
echo " hibernate:" >> ./application.yml | ||
echo " ddl-auto: none" >> ./application.yml | ||
echo " show-sql: true" >> ./application.yml | ||
echo " datasource:" >> ./application.yml | ||
echo " url: ${{ secrets.DB_URL }}" >> ./application.yml | ||
echo " username: ${{ secrets.DB_USERNAME }}" >> ./application.yml | ||
echo " password: ${{ secrets.DB_PASSWORD }}" >> ./application.yml | ||
echo " driver-class-name: com.mysql.cj.jdbc.Driver" >> ./application.yml | ||
echo "jwt:" >> ./application.yml | ||
echo " secret: ${{ secrets.JWT_SECRET }}" >> ./application.yml | ||
echo " access-expired-ms: 3600000000" >> ./application.yml | ||
echo " claims:" >> ./application.yml | ||
echo " auth-key: userId" >> ./application.yml | ||
echo "ai:" >> ./application.yml | ||
echo " gemini:" >> ./application.yml | ||
echo " base-url: https://generativelanguage.googleapis.com/v1/models/gemini-1.0-pro-001:generateContent?key=" >> ./application.yml | ||
echo " api-key: ${{ secrets.AI_API_KEY }}" >> ./application.yml | ||
echo "server:" >> ./application.yml | ||
echo " servlet:" >> ./application.yml | ||
echo " encoding:" >> ./application.yml | ||
echo " charset: UTF-8" >> ./application.yml | ||
echo " enabled: true" >> ./application.yml | ||
echo " force: true" >> ./application.yml | ||
shell: bash | ||
|
||
# Gradle 빌드 | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build -x test | ||
|
||
# Docker 빌드 및 푸시 | ||
- name: Docker build & push | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/hana_piece . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/hana_piece | ||
# 배포 | ||
- name: Deploy | ||
uses: appleboy/ssh-action@master | ||
id: deploy | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ubuntu | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
sudo docker ps | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/hana_piece | ||
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/hana_piece | ||
sudo docker image prune -f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Dockerfile | ||
|
||
# jdk17 Image Start | ||
FROM openjdk:17 | ||
|
||
# 인자 설정 - JAR_File | ||
ARG JAR_FILE=build/libs/*.jar | ||
|
||
# jar 파일 복제 | ||
COPY ${JAR_FILE} app.jar | ||
|
||
# 인자 설정 부분과 jar 파일 복제 부분 합쳐서 진행해도 무방 | ||
#COPY build/libs/*.jar app.jar | ||
|
||
# 실행 명령어 | ||
ENTRYPOINT ["java", "-jar", "app.jar"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters