-
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.
- Loading branch information
Showing
3 changed files
with
94 additions
and
0 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,47 @@ | ||
name: CD | ||
|
||
on: | ||
push: | ||
branches: ["master"] | ||
|
||
env: | ||
S3_BUCKET_NAME: problemsolvingqueue | ||
PROJECT_NAME: psq | ||
|
||
jobs: | ||
build: | ||
name: CD | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '11' | ||
distribution: 'zulu' | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build with Gradle | ||
run: ./gradlew build | ||
shell: bash | ||
|
||
- name: Make zip file | ||
run: zip -r ./$GITHUB_SHA.zip . | ||
shell: bash | ||
|
||
- 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: ${{ secrets.AWS_REGION }} | ||
|
||
- name: Copy script | ||
run: cp ./scripts/*.sh ./deploy | ||
|
||
- name: Upload to S3 | ||
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://$S3_BUCKET_NAME/$PROJECT_NAME/$GITHUB_SHA.zip |
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,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: ubuntu | ||
ApplicationStart: | ||
- location: scripts/start.sh | ||
timeout: 60 | ||
runas: ubuntu |
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,24 @@ | ||
#!/bin/bash | ||
BUILD_JAR=$(ls /home/ubuntu/app/build/libs/*.jar) | ||
JAR_NAME=$(basename $BUILD_JAR) | ||
echo "> build 파일명: $JAR_NAME" >> /home/ubuntu/app/deploy.log | ||
|
||
echo "> build 파일 복사" >> /home/ubuntu/app/deploy.log | ||
DEPLOY_PATH=/home/ubuntu/app/action/ | ||
cp $BUILD_JAR $DEPLOY_PATH | ||
|
||
echo "> 현재 실행중인 애플리케이션 pid 확인" >> /home/ubuntu/app/deploy.log | ||
CURRENT_PID=$(pgrep -f $JAR_NAME) | ||
|
||
if [ -z $CURRENT_PID ] | ||
then | ||
echo "> 현재 구동중인 애플리케이션이 없으므로 종료하지 않습니다." >> /home/ubuntu/app/deploy.log | ||
else | ||
echo "> kill -15 $CURRENT_PID" | ||
kill -15 $CURRENT_PID | ||
sleep 5 | ||
fi | ||
|
||
DEPLOY_JAR=$DEPLOY_PATH$JAR_NAME | ||
echo "> DEPLOY_JAR 배포" >> /home/ubuntu/app/deploy.log | ||
nohup java -jar $DEPLOY_JAR >> /home/ubuntu/deploy.log 2>/home/ubuntu/app/deploy_err.log & |