-
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
5f8d529
commit 6cc7bc8
Showing
2 changed files
with
109 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,50 @@ | ||
name: Java CD with Gradle | ||
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Connect to EC2 via SSH | ||
uses: appleboy/ssh-action@master | ||
env: | ||
APPLICATION_YML: ${{ secrets.APPLICATION_YML }} | ||
APPLICATION_TEST_YML: ${{ secrets.APPLICATION_TEST_YML }} | ||
with: | ||
host: ${{ secrets.HOST }} | ||
username: ${{ secrets.USERNAME }} | ||
password: ${{ secrets.PASSWORD }} | ||
port: ${{ secrets.PORT }} | ||
script_stop: true | ||
envs: APPLICATION_YML, APPLICATION_TEST_YML | ||
# git clone 같은 초기 작업은 ec2에서 먼저 진행 | ||
script: | | ||
cd /home/server/purelabel/PureLabel | ||
git switch dev | ||
git pull origin dev | ||
rm -rf src/main/resources/application.yml | ||
mkdir -p src/main/resources | ||
echo "$APPLICATION_YML" > src/main/resources/application.yml | ||
rm -rf src/test/resources/application.yml | ||
mkdir -p src/test/resources | ||
echo "$APPLICATION_TEST_YML" > src/test/resources/application.yml | ||
chmod +x gradlew | ||
./gradlew clean | ||
./gradlew build | ||
sudo fuser -k -n tcp "${{ secrets.SERVER_PORT }}" || true | ||
nohup java -jar build/libs/*SNAPSHOT.jar > ./output.log 2>&1 & |
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,59 @@ | ||
name: Java CI with Gradle | ||
|
||
#dev 브랜치로 pr할 때 CI 적용 | ||
on: | ||
pull_request: | ||
branches: [ "main" ] | ||
types: [ opened, synchronize ] | ||
push: # push 이벤트 발생 시 | ||
branches: # 타겟 브랜치 | ||
- main | ||
|
||
#build 작업 | ||
jobs: | ||
build: | ||
#작업이 실행될 환경 지정 | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
#각 단계가 순자적으로 진행 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
#JDK 17 설치 | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
|
||
- name: Create main resources directory | ||
run: mkdir -p src/main/resources | ||
|
||
- name: Create test resources directory | ||
run: mkdir -p src/test/resources | ||
|
||
# main의 application.yml 생성 | ||
- name: Set Release YML File | ||
run: | | ||
cd ./src/main/resources | ||
touch ./application.yml | ||
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml | ||
# test의 application.yml 생성 | ||
- name: Set Release Test YML File | ||
run: | | ||
cd ./src/test/resources | ||
touch ./application.yml | ||
echo "${{ secrets.APPLICATION_TEST_YML }}" > ./application.yml | ||
#Gradle 설정 및 의존성 다운 | ||
- name: Setup Gradle | ||
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | ||
|
||
#Permission Denied 해결 | ||
- name: Make gradlew executable | ||
run: chmod +x ./gradlew | ||
|
||
#빌드 작업 실행(테스트도 같이 진행) | ||
- name: Build with Gradle Wrapper | ||
run: ./gradlew build |