-
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
1 parent
60d3407
commit 76ec905
Showing
4 changed files
with
136 additions
and
136 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 |
---|---|---|
@@ -1,73 +1,73 @@ | ||
# This is a basic workflow to help you get started with Actions | ||
|
||
name: Deploy to Amazon EC2 | ||
# Controls when the workflow will run | ||
on: | ||
# Triggers the workflow on push or pull request events but only for the "main" branch | ||
push: | ||
branches: | ||
- main | ||
|
||
env: | ||
AWS_REGION: ap-northeast-2 | ||
S3_BUCKET_NAME: meltingpot-github-actions-s3-bucket | ||
CODE_DEPLOY_APPLICATION_NAME: meltingpot-codedeploy-app | ||
CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: meltingpot-codedeploy-deployment-group | ||
APPLICATION: ${{ secrets.APPLICATION }} | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
environment: production | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '17' | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
|
||
- uses: actions/checkout@v2 | ||
- run: touch ./src/main/resources/application.yml | ||
- run: echo "${{env.APPLICATION}}" > ./src/main/resources/application.yml | ||
- uses: actions/upload-artifact@v2 | ||
with: | ||
name: application.yml | ||
path: ./src/main/resources/application.yml | ||
|
||
- name: Build with Gradle | ||
uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee | ||
with: | ||
arguments: clean build -x test | ||
|
||
- 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 }} | ||
|
||
- 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 . | ||
- 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 | ||
## This is a basic workflow to help you get started with Actions | ||
# | ||
#name: Deploy to Amazon EC2 | ||
## Controls when the workflow will run | ||
#on: | ||
# # Triggers the workflow on push or pull request events but only for the "main" branch | ||
# push: | ||
# branches: | ||
# - main | ||
# | ||
#env: | ||
# AWS_REGION: ap-northeast-2 | ||
# S3_BUCKET_NAME: meltingpot-github-actions-s3-bucket | ||
# CODE_DEPLOY_APPLICATION_NAME: meltingpot-codedeploy-app | ||
# CODE_DEPLOY_DEPLOYMENT_GROUP_NAME: meltingpot-codedeploy-deployment-group | ||
# APPLICATION: ${{ secrets.APPLICATION }} | ||
# | ||
#permissions: | ||
# contents: read | ||
# | ||
#jobs: | ||
# deploy: | ||
# name: Deploy | ||
# runs-on: ubuntu-latest | ||
# environment: production | ||
# | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v3 | ||
# | ||
# - name: Set up JDK 17 | ||
# uses: actions/setup-java@v3 | ||
# with: | ||
# distribution: 'temurin' | ||
# java-version: '17' | ||
# - name: Grant execute permission for gradlew | ||
# run: chmod +x gradlew | ||
# | ||
# - uses: actions/checkout@v2 | ||
# - run: touch ./src/main/resources/application.yml | ||
# - run: echo "${{env.APPLICATION}}" > ./src/main/resources/application.yml | ||
# - uses: actions/upload-artifact@v2 | ||
# with: | ||
# name: application.yml | ||
# path: ./src/main/resources/application.yml | ||
# | ||
# - name: Build with Gradle | ||
# uses: gradle/gradle-build-action@0d13054264b0bb894ded474f08ebb30921341cee | ||
# with: | ||
# arguments: clean build -x test | ||
# | ||
# - 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 }} | ||
# | ||
# - 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 . | ||
# | ||
# - 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 |
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 |
---|---|---|
@@ -1,23 +1,23 @@ | ||
version: 0.0 | ||
os: linux | ||
|
||
files: | ||
- source: / | ||
destination: /home/ubuntu/EwhaSinmungo-Back | ||
overwrite: yes | ||
file_exists_behavior: OVERWRITE | ||
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 | ||
#version: 0.0 | ||
#os: linux | ||
# | ||
#files: | ||
# - source: / | ||
# destination: /home/ubuntu/EwhaSinmungo-Back | ||
# overwrite: yes | ||
#file_exists_behavior: OVERWRITE | ||
#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 |
---|---|---|
@@ -1,21 +1,21 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROJECT_ROOT="/home/ubuntu/EwhaSinmungo-Back" | ||
JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
|
||
APP_LOG="$PROJECT_ROOT/application.log" | ||
ERROR_LOG="$PROJECT_ROOT/error.log" | ||
DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
|
||
TIME_NOW=$(date +%c) | ||
|
||
# build 파일 복사 | ||
echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG | ||
cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE | ||
|
||
# jar 파일 실행 | ||
echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG | ||
nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & | ||
|
||
CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
echo "$TIME_NOW > 실행된 프로세스 아이디 $CURRENT_PID 입니다." >> $DEPLOY_LOG | ||
##!/usr/bin/env bash | ||
# | ||
#PROJECT_ROOT="/home/ubuntu/EwhaSinmungo-Back" | ||
#JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
# | ||
#APP_LOG="$PROJECT_ROOT/application.log" | ||
#ERROR_LOG="$PROJECT_ROOT/error.log" | ||
#DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
# | ||
#TIME_NOW=$(date +%c) | ||
# | ||
## build 파일 복사 | ||
#echo "$TIME_NOW > $JAR_FILE 파일 복사" >> $DEPLOY_LOG | ||
#cp $PROJECT_ROOT/build/libs/*.jar $JAR_FILE | ||
# | ||
## jar 파일 실행 | ||
#echo "$TIME_NOW > $JAR_FILE 파일 실행" >> $DEPLOY_LOG | ||
#nohup java -jar $JAR_FILE > $APP_LOG 2> $ERROR_LOG & | ||
# | ||
#CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
#echo "$TIME_NOW > 실행된 프로세스 아이디 $CURRENT_PID 입니다." >> $DEPLOY_LOG |
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 |
---|---|---|
@@ -1,19 +1,19 @@ | ||
#!/usr/bin/env bash | ||
|
||
PROJECT_ROOT="/home/ubuntu/EwhaSinmungo-Back" | ||
JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
|
||
DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
|
||
TIME_NOW=$(date +%c) | ||
|
||
# 현재 구동 중인 애플리케이션 pid 확인 | ||
CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
|
||
# 프로세스가 켜져 있으면 종료 | ||
if [ -z $CURRENT_PID ]; then | ||
echo "$TIME_NOW > 현재 실행중인 애플리케이션이 없습니다" >> $DEPLOY_LOG | ||
else | ||
echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG | ||
kill -15 $CURRENT_PID | ||
fi | ||
##!/usr/bin/env bash | ||
# | ||
#PROJECT_ROOT="/home/ubuntu/EwhaSinmungo-Back" | ||
#JAR_FILE="$PROJECT_ROOT/spring-webapp.jar" | ||
# | ||
#DEPLOY_LOG="$PROJECT_ROOT/deploy.log" | ||
# | ||
#TIME_NOW=$(date +%c) | ||
# | ||
## 현재 구동 중인 애플리케이션 pid 확인 | ||
#CURRENT_PID=$(pgrep -f $JAR_FILE) | ||
# | ||
## 프로세스가 켜져 있으면 종료 | ||
#if [ -z $CURRENT_PID ]; then | ||
# echo "$TIME_NOW > 현재 실행중인 애플리케이션이 없습니다" >> $DEPLOY_LOG | ||
#else | ||
# echo "$TIME_NOW > 실행중인 $CURRENT_PID 애플리케이션 종료 " >> $DEPLOY_LOG | ||
# kill -15 $CURRENT_PID | ||
#fi |