Skip to content

Commit

Permalink
feat: gradle 캐시 기능 및 불필요한 파일 s3 업로드시 제거하도록 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
juno-junho committed Apr 15, 2024
1 parent e2f40b8 commit 6c96c03
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
20 changes: 15 additions & 5 deletions .github/workflows/manual-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@ jobs:
java-version: '17'
distribution: 'temurin'

- name: Cache Gradle packages # gradle cache를 통한 workflow 속도 개선
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Permission for gradlew
run: chmod +x ./gradlew
shell: bash

- name: Gradle Build Action
uses: gradle/gradle-build-action@bd5760595778326ba7f1441bcf7e88b49de61a25
with:
arguments: bootJar
run: ./gradlew bootJar

- name: Make Zip File
run: zip -qq -r ./$GITHUB_SHA.zip .
- name: Make Zip File # appspec.yml, scripts 폴더, jar 파일만 압축
run: zip -qq -r ./$GITHUB_SHA.zip ./appspec.yml ./scripts/ ${{ env.JAR_PATH }}
shell: bash
env:
JAR_PATH: ./build/libs/*SNAPSHOT.jar

- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v3
Expand Down
12 changes: 4 additions & 8 deletions scripts/deploy.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
#!/usr/bin/env bash

source /home/ubuntu/action/scripts/properties.sh

PROJECT_NAME=space-club-backend
REPOSITORY=/home/ubuntu/action
PACKAGE=$REPOSITORY/build/libs/
JAR_NAME=$(ls -tr $PACKAGE | grep 'SNAPSHOT.jar' | tail -n 1)
JAR_PATH=$PACKAGE$JAR_NAME

echo $JAR_NAME
echo $JAR_PATH
JAR_NAME=$(ls -tr $REPOSITORY | grep 'SNAPSHOT.jar' | tail -n 1)
JAR_PATH=$REPOSITORY$JAR_NAME

cd $REPOSITORY

Expand All @@ -25,8 +21,8 @@ else
fi

echo "> 배포 - $JAR_PATH"
# jar path 권한 수정
chmod +x $JAR_PATH

echo ${encrypt} > /home/ubuntu/log/nohup_encrypt_log.out

# 백그라운드에서 실행 및 로깅
sudo nohup java -jar $JAR_PATH --spring.profiles.active=develop --jasypt.encryptor.password=${encrypt} > /home/ubuntu/log/nohup_log.out 2> /home/ubuntu/log/nohup_error.out &

0 comments on commit 6c96c03

Please sign in to comment.