Skip to content

Commit

Permalink
Merge pull request #44 from team-nabi/NABI-254--beommo-hotfix--CI-fail
Browse files Browse the repository at this point in the history
NABI-254--delete : 기존 테스트 삭제
  • Loading branch information
BeommoKoo-dev authored Nov 17, 2023
2 parents 9d1a985 + 6768b95 commit 9cbd445
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 235 deletions.
33 changes: 16 additions & 17 deletions .github/workflows/CICD.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ on:

env:
PROJECT_NAME: nabi
BUCKET_NAME: nabi-ci-cd-bucket
CODE_DEPLOY_APP_NAME: nabi-cicd
DEPLOYMENT_GROUP_NAME: nabi-instance-group
BUCKET_NAME: team-01-bucket
CODE_DEPLOY_APP_NAME: team01-codedeploy
DEPLOYMENT_GROUP_NAME: team01-instance-group

permissions:
contents: read

# workflow는 한개 이상의 job을 가지며, 각 job은 여러 step에 따라 단계를 나눌 수 있음
jobs:
build:
name: CI
# 해당 jobs에서 아래의 steps들이 어떠한 환경에서 실행될 것인지를 지정
runs-on: ubuntu-20.04

# 해당 yml 내에서 사용할 key - value


steps:
# 작업에서 액세스할 수 있도록 $GITHUB_WORKSPACE에서 저장소를 체크아웃
# 작업에서 액세스할 수 있도록 $GITHUB_WORKSPACE에서 저장소를 체크아웃
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
Expand All @@ -34,13 +34,12 @@ jobs:
distribution: 'temurin'

# application.properties를 프로젝트에 포함
- name: add Application.yml
run: touch ./src/main/resources/application.yml
shell: bash
- name: Make application.properties
run: |
cd ./src/main/resources
touch ./application.properties
- name: copy Application.yml
run:
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml
echo "${{ secrets.DATABASE_PROPERTIES }}" >> ./application.properties
shell: bash

- name: Setup MySQL
Expand All @@ -64,7 +63,7 @@ jobs:
- name: Build with Gradle
run: ./gradlew build
shell: bash

- name: Make zip file
run: zip -r ./$GITHUB_SHA.zip .
shell: bash
Expand All @@ -75,15 +74,15 @@ jobs:
aws-access-key-id: ${{ secrets.ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.SECRET_KEY }}
aws-region: ap-northeast-2

# script files 복사
- name: Copy script
run: cp ./scripts/*.sh ./deploy

# S3에 빌드 결과 업로드
- name: Upload to S3
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip

# Deploy 실행
- name: Code Deploy To EC2 instance
run: aws deploy create-deployment
Expand Down
26 changes: 12 additions & 14 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
#!/bin/bash
BUILD_JAR=$(ls $REPOSITORY/build/libs/*.jar)
JAR_NAME=$(basename $BUILD_JAR)
echo "> build 파일명: $JAR_NAME" >> /home/ubuntu/action/deploy.log
#!/usr/bin/env bash

echo "> build 파일 복사" >> /home/ubuntu/action/deploy.log
DEPLOY_PATH=/home/ubuntu/action/
cp $BUILD_JAR $DEPLOY_PATH
REPOSITORY=/home/ubuntu/nabi
cd $REPOSITORY

echo "> 현재 실행중인 애플리케이션 pid 확인" >> /home/ubuntu/action/deploy.log
CURRENT_PID=$(pgrep -f $JAR_NAME)
APP_NAME=nabi
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep 'SNAPSHOT.jar' | tail -n 1)
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME

CURRENT_PID=$(pgrep -f $APP_NAME)

if [ -z $CURRENT_PID ]
then
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> /home/ubuntu/action/deploy.log
echo "> 종료할 애플리케이션이 없습니다."
else
echo "> kill -15 $CURRENT_PID"
echo "> kill -9 $CURRENT_PID"
kill -15 $CURRENT_PID
sleep 5
fi

DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME
echo "> DEPLOY_JAR 배포" >> /home/ubuntu/today/deploy.log
nohup java -jar $DEPLOY_JAR >> /home/ubuntu/today/deploy.log 2>/home/ubuntu/action/deploy_err.log &
echo "> Deploy - $JAR_PATH "
nohup java -jar $JAR_PATH > /dev/null 2> /dev/null < /dev/null &

This file was deleted.

This file was deleted.

0 comments on commit 9cbd445

Please sign in to comment.