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/CD 및 기존 develop 브랜치 Merge #47

Merged
merged 22 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
a060672
Merge branch 'main' of github.com:Nawabali-project/Nawabali-BE into d…
peter-jaesungyu Apr 2, 2024
f5b0589
FEAT : CI/CD 기능 구현
peter-jaesungyu Apr 2, 2024
98a17af
FEAT : ping-pong 연결 확인 HelloController 임시 추가
peter-jaesungyu Apr 2, 2024
3684407
FIX : yml 경로 수정
peter-jaesungyu Apr 2, 2024
d1cdbf0
FIX : Gradle 적용을 위해 폴더 경로 임시 변경
peter-jaesungyu Apr 2, 2024
4807aa7
FIX : 폴더 변경에 따른 경로 변경
peter-jaesungyu Apr 2, 2024
30c22b0
FIX : role to assume 추가
peter-jaesungyu Apr 2, 2024
0c19c0e
FIX : role to assume 롤백 및 plane-jar 제외
peter-jaesungyu Apr 3, 2024
8ec8512
FIX : Gradle cache 버전업
peter-jaesungyu Apr 3, 2024
9f8132f
FIX : jar 파일 수정
peter-jaesungyu Apr 3, 2024
b8b55cd
FIX : plane-jar 제외 임시 롤백
peter-jaesungyu Apr 3, 2024
7489882
FIX : 애플리케이션 이름 오타 수정
peter-jaesungyu Apr 3, 2024
d1a169b
FIX : Gradle cashe 버전업
peter-jaesungyu Apr 3, 2024
ea3bcf2
FIX : 무조건 200 OK 반환하는 API permitall 설정 추가
peter-jaesungyu Apr 3, 2024
1d37366
FIX : 폴더 구조 롤백
peter-jaesungyu Apr 4, 2024
8441579
MERGE : 폴더 구조 롤백한 develop 브랜치와 feature/38/cicd 브랜치 머지
peter-jaesungyu Apr 4, 2024
87f99f6
FEAT : swagger HTTPS 적용 및 CORS 설정 추가
peter-jaesungyu Apr 4, 2024
02cd1ed
FIX : 주소 오타 수정
peter-jaesungyu Apr 4, 2024
5d37522
FIX : redis 호스트 및 비밀번호, EC2 기준으로 수정
peter-jaesungyu Apr 4, 2024
0efc4cf
FIX : 자주 발생하는 accessToken 관련 로그 임시 주석처리
peter-jaesungyu Apr 4, 2024
78acfb4
Merge commit
peter-jaesungyu Apr 4, 2024
0ccfac7
Fix : redis 관련 설정 localhost와 ec2 서버 코드 분리 및 Generated파일
peter-jaesungyu Apr 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .github/workflows/cicd_production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
name: Deploy to Amazon EC2

on:
push:
branches: [ "main" ,"develop","feature/38/cicd"]
pull_request:
branches: [ "main", "develop","feature/38/cicd"]

env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: sparta-project-build
CODE_DEPLOY_APPLICATION_NAME: codedeploy
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: codedeploy-deployment-group-production

permissions:
contents: read

jobs:
deploy:
name: Deploy
runs-on: ubuntu-latest
environment: production

steps:
# (1) 기본 체크아웃
- name: Checkout
uses: actions/checkout@v4

# (2) JDK 17 세팅
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'

# (3) application.properties 생성
- name: Make an application.properties
run: |
mkdir -p ./src/main/resources
echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.properties
cat ./src/main/resources/application.properties

# (4) Gradle build (Test 제외)
- name: Cache Gradle packages
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-

- name: Setup Gradle and Build
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.7
arguments: clean build -x test


# (5) AWS 인증 (IAM 사용자 Access Key, Secret Key 활용)
- name: Configure AWS credentials
uses: aws-actions/[email protected]
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ env.AWS_REGION }}


# (6) 빌드 결과물을 S3 버킷에 업로드
- name: Upload to AWS S3
run: |
aws deploy push \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--ignore-hidden-files \
--s3-location s3://$S3_BUCKET_NAME/$GITHUB_SHA.zip \
--source .

# (7) S3 버킷에 있는 파일을 대상으로 CodeDeploy 실행
- name: Deploy to AWS EC2 from S3
run: |
aws deploy create-deployment \
--application-name ${{ env.CODE_DEPLOY_APPLICATION_NAME }} \
--deployment-config-name CodeDeployDefault.AllAtOnce \
--deployment-group-name ${{ env.CODE_DEPLOY_DEPLOYMENT_GROUP_NAME }} \
--s3-location bucket=$S3_BUCKET_NAME,key=$GITHUB_SHA.zip,bundleType=zip
58 changes: 43 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,15 +1,43 @@
/.idea/dataSources/c94156e2-616b-4f92-8094-766134428738.xml
/.idea/dataSources.local.xml
/.idea/dataSources/c94156e2-616b-4f92-8094-766134428738/storage_v2/_src_/schema/information_schema.FNRwLQ.meta
/.idea/modules.xml
/.idea/dataSources/c94156e2-616b-4f92-8094-766134428738/storage_v2/_src_/schema/mysql.osA4Bg.meta
/.idea/modules/nawabali.main.iml
/.idea/dataSources/c94156e2-616b-4f92-8094-766134428738/storage_v2/_src_/schema/nawabali.OVuTfg.meta
/.idea/Nawabali-BE.iml
/.idea/dataSources/c94156e2-616b-4f92-8094-766134428738/storage_v2/_src_/schema/performance_schema.kIw0nw.meta
/.idea/dataSources/c94156e2-616b-4f92-8094-766134428738/storage_v2/_src_/schema/sys.zb4BAA.meta
/.idea/vcs.xml
/.idea/workspace.xml
/.idea/uiDesigner.xml
/nawabali/src/main/generated/com/nawabali/nawabali/domain/QComment.java
/nawabali/src/main/generated/com/nawabali/nawabali/domain/QLike.java
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

# properties 제외 설정
/src/main/resources/*.properties
/src/main/resources/application.properties
src/main/resources/application.properties

1 change: 1 addition & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/dataSources.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
version: 0.0
os: linux

files:
- source: /
destination: /home/ubuntu/app
overwrite: yes

permissions:
- object: /
pattern: "**"
owner: ubuntu
group: ubuntu

hooks:
AfterInstall:
- location: scripts/stop.sh
timeout: 60
runas: ubuntu
ApplicationStart:
- location: scripts/start.sh
timeout: 60
runas: ubuntu

12 changes: 11 additions & 1 deletion nawabali/build.gradle → build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,16 @@ clean {
delete file(generated)
}

tasks.named('test') {
// CI 빌드 test 제외하기 위해 주석처리
//tasks.named('test') {
// useJUnitPlatform()
//}

test {
useJUnitPlatform()
}

//// 빌드 시 plain jar 파일은 만들어지지 않기 위해 추가
//jar {
// enabled = false
//}
0 nawabali/gradlew → gradlew
100755 → 100644
File renamed without changes.
File renamed without changes.
43 changes: 0 additions & 43 deletions nawabali/.gitignore

This file was deleted.

This file was deleted.

This file was deleted.

Loading