Skip to content

Commit

Permalink
Merge pull request #148 from Team-HMH/deploy/#145-build-prod-server
Browse files Browse the repository at this point in the history
deploy - prod μ„œλ²„λ₯Ό μœ„ν•œ CI/CD ν”Œλ‘œμš° μˆ˜μ •
  • Loading branch information
kseysh authored May 29, 2024
2 parents 7269436 + 262e255 commit 466674c
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/hmh-cd-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
aws-region: ${{ secrets.AWS_REGION }}

- name: πŸš€ s3 upload
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/prod/deploy/$GITHUB_SHA.zip # μˆ˜μ • κ³ λ €
run: aws s3 cp --region ap-northeast-2 ./$GITHUB_SHA.zip s3://${{matrix.s3-bucket}}/prod/deploy/$GITHUB_SHA.zip

- name: β˜€οΈ CodeDeploy~!
run: aws deploy create-deployment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: 🏭 APPLICATION-BUILD!
on:
pull_request:
branches: [ "develop" ]
push:
branches: [ "develop" ]

permissions:
contents: read
Expand Down
40 changes: 40 additions & 0 deletions .github/workflows/hmh-ci-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 🏭 APPLICATION-BUILD!

on:
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'

- name: Copy application.yml
run: |
mkdir ./src/main/resources
touch ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION_PROD_YML }}" >> ./src/main/resources/application.yml
cat ./src/main/resources/application.yml
shell: bash

- name: Grant execute permission for gradlew
run: |
chmod +x gradlew
- name: Build with Gradle
run: |
./gradlew clean build
18 changes: 11 additions & 7 deletions script/start.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
# μΈμŠ€ν„΄μŠ€μ— 클둠 받은 디렉토리 이름을 `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)

Expand All @@ -20,7 +16,15 @@ JAR_PID=$(pgrep -f $JAR_NAME)
fi

echo "> $JAR_PATH 배포" #3
# shellcheck disable=SC2153
# shellcheck disable=SC2024

source ~/.bashrc
sudo nohup java -jar -Dspring.profiles.active=prod "$JAR_PATH" >nohup.out 2>&1 </dev/null &

if [ "$DEPLOYMENT_GROUP_NAME" == "hmh-dev-deploy-group" ]
then
sudo nohup java -jar -Dspring.profiles.active=dev "$JAR_PATH" >nohup.out 2>&1 </dev/null &
fi

if [ "$DEPLOYMENT_GROUP_NAME" == "hmh-prod-deploy-group" ]
then
sudo nohup java -jar -Dspring.profiles.active=prod "$JAR_PATH" >nohup.out 2>&1 </dev/null &
fi

0 comments on commit 466674c

Please sign in to comment.