Skip to content

Commit

Permalink
Merge branch 'develop' into feat/EPIC-80-post
Browse files Browse the repository at this point in the history
  • Loading branch information
ibaesuyeon committed Apr 13, 2024
2 parents 709315f + b4b0079 commit eab601b
Show file tree
Hide file tree
Showing 16 changed files with 259 additions and 335 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: CI and Deploy to Amazon EC2

on:
# Triggers the workflow on push events but only for the "main" branch
push:
branches: [ "main", "develop" ]

# 본인이 설정한 값을 여기서 채워넣습니다.
# 리전, 버킷 이름, CodeDeploy 앱 이름, CodeDeploy 배포 그룹 이름
env:
AWS_REGION: ap-northeast-2
S3_BUCKET_NAME: github-actions-s3-management
CODE_DEPLOY_APPLICATION_NAME: codedeploy-management-app
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: codedeploy-deployment-group

permissions:
contents: read

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

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

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

## create application-rds.yml && application-s3.yml && application-auth.yml && forbidden-words.txt
- name: create application.properties file
run: |
touch ./src/main/resources/application-prod.yml
echo "${{ secrets.DATABASE_YML }}" | base64 --decode > src/main/resources/application-prod.yml
#추가
- name: Make Gradle Wrapper script executable
run: chmod +x /home/runner/work/STUDIO-EYE-MANAGEMENT-SERVICE/STUDIO-EYE-MANAGEMENT-SERVICE/gradlew

# (3) Gradle build (Test 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee
with:
arguments: clean build -x test

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

# (5) 빌드 결과물을 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 .
# (6) 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
77 changes: 0 additions & 77 deletions .github/workflows/gradle-cd.yml

This file was deleted.

82 changes: 0 additions & 82 deletions .github/workflows/gradle-ci.yml

This file was deleted.

46 changes: 46 additions & 0 deletions .github/workflows/sonarqube.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build

on:
push:
branches:
- main
- develop

jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions: read-all
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up JDK 17
uses: actions/setup-java@v1
with:
java-version: 17

- name: Cache SonarQube packages
uses: actions/cache@v1
with:
path: ~/.sonar/cache
key: ${{ runner.os }}-sonar
restore-keys: ${{ runner.os }}-sonar

- name: Cache Gradle packages
uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }}
restore-keys: ${{ runner.os }}-gradle

#추가
- name: Make Gradle Wrapper script executable
run: chmod +x ./gradlew

- name: Build and analyze
env:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
run: ./gradlew build -x test sonar --info
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ out/
.vscode/

### application.yml ###
application.yml
application-local.yml
application-prod.yml
application-test.yml
4 changes: 0 additions & 4 deletions Dockerfile

This file was deleted.

23 changes: 23 additions & 0 deletions appspec.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
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: root
ApplicationStart:
- location: scripts/start.sh
timeout: 60
runas: root
18 changes: 18 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
plugins {
id 'java'
id "org.sonarqube" version "4.4.1.3373"
id 'org.springframework.boot' version '3.1.3'
id 'io.spring.dependency-management' version '1.1.3'
id 'jacoco'
Expand Down Expand Up @@ -66,6 +67,9 @@ dependencies {
implementation 'io.jsonwebtoken:jjwt:0.9.1'
implementation 'javax.xml.bind:jaxb-api:2.3.0'

// SonarQube
implementation 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'

// test container
testImplementation "org.testcontainers:junit-jupiter:1.17.2"
testImplementation "org.testcontainers:mysql:1.17.2"
Expand All @@ -77,6 +81,20 @@ dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-aws:2.2.6.RELEASE'
}

sonarqube {
properties {
property "sonar.projectKey", "sonar-management"
property "sonar.projectName", "sonar-management"
// property "sonar.sources", "src" // 소스 경로
// property "sonar.language", "java" // 언어
// property "sonar.java.source", "17"
// property "sonar.sourceEncoding", "UTF-8"
// property "sonar.profile", "Sonar way" // SonarQube 에서 분석할 때 적용할 프로필(분석할 수준 설정)
// property "sonar.java.binaries", "${buildDir}/classes" // 자바 클래스 파일위치
// property "sonar.test.inclusions", "**/*Test.java" // 코드 분석에 사용할 테스트 소스
}
}

dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
Expand Down
16 changes: 0 additions & 16 deletions docker-compose.yml

This file was deleted.

Loading

0 comments on commit eab601b

Please sign in to comment.