-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FEATURE] Github Action 을 통한 CI/CD 구축 (#43)
* refactor: 스프링 프로필 환경변수로 설정 (#36) * feat: 운영, 개발 프로필 설정 (#36) * refactor: 프로필별 설정 (#36) * refactor: jpa properties 설정 (#36) * refactor: h2-console URL 수정 (#36) * refactor: JWT_SECRET 기본값 설정 (#36) * refactor: 아카이브 파일 제외 (#36) * chore: 깃허브 액션 ci/cd 작성 (#36) * feat: Redis 서버 연결 실패 오류 핸들링 (#36) * feat: Redis 서버 오류 핸들링 (#36) * feat: Redis 컨테이너 설정 추가 (#36) * feat: 스프링 프로필 설정 (#36) * test: 깃허브 액션 테스트 (#36) * test: 깃허브 액션 운영 테스트 (#36) * test: 깃허브 액션 운영 테스트 완료 (#36) * docs: README 수정 (#36) * chore: 버전 수정 (#36) --------- Co-authored-by: hyunmin0317 <choihm9903@naver.com>
- Loading branch information
1 parent
c81a2e6
commit 28fda71
Showing
13 changed files
with
223 additions
and
16 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,55 @@ | ||
name: Dev CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '17' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
env: | ||
SPRING_PROFILE: dev | ||
JWT_SECRET: ${{ secrets.JWT_SECRET }} | ||
DB_URL: ${{ secrets.DB_URL }} | ||
DB_USERNAME: ${{ secrets.DB_USERNAME }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
REDIS_URL: ${{ secrets.REDIS_URL }} | ||
REDIS_PORT: ${{ secrets.REDIS_PORT }} | ||
|
||
- name: Get current time | ||
uses: josStorer/get-current-time@v2.0.2 | ||
id: current-time | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
utcOffset: "+09:00" | ||
|
||
- name: Set artifact | ||
run: echo "artifact=$(ls ./build/libs)" >> $GITHUB_ENV | ||
|
||
- name: Beanstalk Deploy | ||
uses: einaregilsson/beanstalk-deploy@v20 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
application_name: jwt-dev | ||
environment_name: jwt-dev-env | ||
version_label: github-action-${{steps.current-time.outputs.formattedTime}} | ||
region: ap-northeast-2 | ||
deployment_package: ./build/libs/${{env.artifact}} |
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,55 @@ | ||
name: Release CI/CD | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'corretto' | ||
java-version: '17' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
env: | ||
SPRING_PROFILE: release | ||
JWT_SECRET: ${{ secrets.JWT_SECRET }} | ||
DB_URL: ${{ secrets.DB_URL }} | ||
DB_USERNAME: ${{ secrets.DB_USERNAME }} | ||
DB_PASSWORD: ${{ secrets.DB_PASSWORD }} | ||
REDIS_URL: ${{ secrets.REDIS_URL }} | ||
REDIS_PORT: ${{ secrets.REDIS_PORT }} | ||
|
||
- name: Get current time | ||
uses: josStorer/get-current-time@v2.0.2 | ||
id: current-time | ||
with: | ||
format: YYYY-MM-DDTHH-mm-ss | ||
utcOffset: "+09:00" | ||
|
||
- name: Set artifact | ||
run: echo "artifact=$(ls ./build/libs)" >> $GITHUB_ENV | ||
|
||
- name: Beanstalk Deploy | ||
uses: einaregilsson/beanstalk-deploy@v20 | ||
with: | ||
aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
application_name: jwt-release | ||
environment_name: jwt-release-env | ||
version_label: github-action-${{steps.current-time.outputs.formattedTime}} | ||
region: ap-northeast-2 | ||
deployment_package: ./build/libs/${{env.artifact}} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,29 @@ | ||
# Spring Boot JWT | ||
|
||
> Spring Boot, Spring Security를 이용한 JWT 인증·인가 서버 템플릿 | ||
## ⚒️ Tech Stack | ||
|
||
* #### Backend | ||
<img src="https://img.shields.io/badge/Java-17-007396?style=round-square&logo=oracle&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/Spring-6DB33F?style=round-square&logo=Spring&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/Spring%20Boot-6DB33F?style=round-square&logo=springboot&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/Spring%20Security-6DB33F?style=round-square&logo=SpringSecurity&logoColor=white"/> | ||
|
||
* #### Build Tool | ||
<img src="https://img.shields.io/badge/Gradle-02303A?style=round-square&logo=Gradle&logoColor=white"/> | ||
|
||
* #### DBMS | ||
<img src="https://img.shields.io/badge/MySQL-4479A1?style=round-square&logo=MySQL&logoColor=white"/> | ||
|
||
* #### CI/CD | ||
<img src="https://img.shields.io/badge/Git-F05032?style=round-square&logo=Git&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/GitHub-181717?style=round-square&logo=github&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/GitHub Actions-2088FF?style=round-square&logo=githubactions&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/Docker-2496ED?style=round-square&logo=docker&logoColor=white"/> | ||
|
||
* #### Deploy | ||
<img src="https://img.shields.io/badge/AWS-232F3E?style=round-square&logo=amazonwebservices&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/EC2-FF9900?style=round-square&logo=amazonec2&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/RDS-527FFF?style=round-square&logo=amazonrds&logoColor=white"/> | ||
<img src="https://img.shields.io/badge/Elastic Beanstalk-FF9900?style=round-square&logo=awselasticloadbalancing&logoColor=white"/> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
version: '3' | ||
|
||
services: | ||
redis: | ||
image: redis:latest | ||
container_name: jwt-redis | ||
ports: | ||
- "6379:6379" |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
spring: | ||
datasource: | ||
url: ${DB_URL} | ||
username: ${DB_USERNAME} | ||
password: ${DB_PASSWORD} | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
|
||
data: | ||
redis: | ||
host: ${REDIS_URL} | ||
port: ${REDIS_PORT} | ||
|
||
jpa: | ||
properties: | ||
hibernate: | ||
dialect: org.hibernate.dialect.MySQLDialect | ||
show_sql: true | ||
format_sql: true | ||
|
||
hibernate: | ||
ddl-auto: update |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
spring: | ||
datasource: | ||
url: ${DB_URL} | ||
username: ${DB_USERNAME} | ||
password: ${DB_PASSWORD} | ||
driver-class-name: com.mysql.cj.jdbc.Driver | ||
|
||
data: | ||
redis: | ||
host: ${REDIS_URL} | ||
port: ${REDIS_PORT} | ||
|
||
jpa: | ||
properties: | ||
hibernate: | ||
dialect: org.hibernate.dialect.MySQLDialect | ||
show_sql: true | ||
format_sql: true | ||
|
||
hibernate: | ||
ddl-auto: none |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
spring: | ||
profiles: | ||
active: local | ||
active: ${SPRING_PROFILE:local} | ||
|
||
jwt: | ||
secret: ${JWT_SECRET} | ||
secret: ${JWT_SECRET:secret} | ||
token: | ||
access-expiration-time: 1800 # 30 minutes | ||
refresh-expiration-time: 1209600 # 14 days |