diff --git a/.github/templates/issue/example_bug_report.md b/.github/templates/issue/example_bug_report.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/templates/issue/example_feature_request.md b/.github/templates/issue/example_feature_request.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/templates/pr/example_pull_request_template.md b/.github/templates/pr/example_pull_request_template.md new file mode 100644 index 0000000..e69de29 diff --git a/.github/workflows/SKT_T1_CD.yml b/.github/workflows/SKT_T1_CD.yml new file mode 100644 index 0000000..4da9237 --- /dev/null +++ b/.github/workflows/SKT_T1_CD.yml @@ -0,0 +1,59 @@ +name: πŸš€ SKT-T1-APPLICATION-DEPLOY! + +on: + push: + branches: [ 'main' ] + +jobs: + build: + runs-on: ubuntu-latest + strategy: + matrix: + codedeploy-application-name: [ skt-t1-app ] + deployment-group-name: [ skt-t1-app-deploy-group ] + s3-bucket: [ skt-t1-app ] + + + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'corretto' + java-version: '17' + + - name: mkdir resources folder + run: touch ./src/main/resources/application.yml + shell: bash + + - name: copy yaml file + run: echo "${{ secrets.APPLICATION_YML }}" > ./src/main/resources/application.yml + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: 🐈 Gradle Build + run: ./gradlew clean build + + - name: πŸ“‚ Make zip file + run: zip -r ./$GITHUB_SHA.zip . + + - name: πŸͺ£ S3 upload + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }} + aws-region: ap-northeast-2 + + - name: πŸš€ s3 upload + run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/deploy/$GITHUB_SHA.zip + + - name: β˜€οΈ CodeDeploy~! + run: aws deploy create-deployment + --application-name ${{matrix.codedeploy-application-name}} + --deployment-group-name ${{matrix.deployment-group-name}} + --s3-location bucket=${{matrix.s3-bucket}},bundleType=zip,key=deploy/$GITHUB_SHA.zip + --file-exists-behavior OVERWRITE + --region ap-northeast-2 \ No newline at end of file diff --git a/.github/workflows/SKT_T1_CI.yml b/.github/workflows/SKT_T1_CI.yml new file mode 100644 index 0000000..a272fe5 --- /dev/null +++ b/.github/workflows/SKT_T1_CI.yml @@ -0,0 +1,49 @@ +name: 🏭 SKT-T1-APPLICATION-BUILD! + +# ν•΄λ‹Ή Action이 μ‹€ν–‰λ˜λŠ” Trigger +on: + pull_request: + branches: [ "dev" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + + # 1) μ›Œν¬ν”Œλ‘œμš° μ‹€ν–‰ μ „ 기본적으둜 체크아웃 ν•„μš” + - name: checkout + uses: actions/checkout@v3 + + # 2) JDK 11버전 μ„€μΉ˜, λ‹€λ₯Έ JDK 버전을 μ‚¬μš©ν•˜λ‹€λ©΄ μˆ˜μ • + - name: Set up JDK 17 + uses: actions/setup-java@v3 + with: + java-version: '17' + distribution: 'corretto' + + # 3) ν™˜κ²½λ³€μˆ˜ 파일 생성 + - name: Copy application-local.yml + run: | + # application.yml 생성 + touch ./src/main/resources/application.yml + + # application.yml 파일 κ°’ μž…λ ₯ + echo "${{ secrets.APPLICATION_YML }}" >> ./src/main/resources/application.yaml + + # application.yaml 파일 확인 + cat ./src/main/resources/application.yaml + shell: bash + + # 이 μ›Œν¬ν”Œλ‘œμš°λŠ” gradle build + - name: Grant execute permission for gradlew + run: | + chmod +x gradlew + + - name: Build with Gradle + run: | + ./gradlew build -x test diff --git a/appspec.yml b/appspec.yml new file mode 100644 index 0000000..efd4c13 --- /dev/null +++ b/appspec.yml @@ -0,0 +1,15 @@ +version: 0.0 +os: linux + +files: + - source: / + destination: /home/ubuntu/app +hooks: + ApplicationStop: + - location: script/stop.sh + timeout: 60 + runas: root + AfterInstall: + - location: script/start.sh + timeout: 60 + runas: root \ No newline at end of file diff --git a/script/start.sh b/script/start.sh new file mode 100644 index 0000000..018e845 --- /dev/null +++ b/script/start.sh @@ -0,0 +1,25 @@ +# μΈμŠ€ν„΄μŠ€μ— 클둠 받은 디렉토리 이름을 `app`으둜 λ°”κΏ”μ•Όν•©λ‹ˆλ‹€. +APPLICATION_PATH=/home/ubuntu/app +# shellcheck disable=SC2164 +cd $APPLICATION_PATH + +# shellcheck disable=SC2010 +JAR_NAME=$(ls $APPLICATION_PATH/build/libs/ | grep '.jar' | tail -n 1) + +# shellcheck disable=SC2034 +JAR_PATH=build/libs/$JAR_NAME +JAR_PID=$(pgrep -f $JAR_NAME) + + if [ -z $JAR_PID ] + then + echo "> ν˜„μž¬ ꡬ동쀑인 μ• ν”Œλ¦¬μΌ€μ΄μ…˜μ΄ μ—†μœΌλ―€λ‘œ μ’…λ£Œν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€." + else + echo "> sudo kill -15 $JAR_PID" + sudo kill -15 $JAR_PID + sleep 10 + fi + + echo "> $JAR_PATH 배포" #3 + # shellcheck disable=SC2153 + # shellcheck disable=SC2024 + sudo nohup java -jar -Dspring.profiles.active=prod "$JAR_PATH" >nohup.out 2>&1