-
Notifications
You must be signed in to change notification settings - Fork 2
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
1 changed file
with
67 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,67 @@ | ||
name: GoalBetting CI/CD with Gradle, Github Actions | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
pull_request: | ||
branches: [ "develop" ] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: 체크아웃 | ||
uses: actions/checkout@v3 | ||
|
||
- name: Gradle 캐싱 | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
~/.gradle/caches | ||
~/.gradle/wrapper | ||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | ||
restore-keys: | | ||
${{ runner.os }}-gradle- | ||
- name: JDK 17 설치 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: 17 | ||
distribution: adopt | ||
|
||
- name: 빌드 권한 부여 | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: 프로젝트 빌드 | ||
run: ./gradlew clean build | ||
shell: bash | ||
|
||
- name: API EC2 인스턴스 접속 및 실행 중인 애플리케이션 종료 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script: | | ||
echo `sudo fuser 8080/tcp` | ||
sudo fuser -k 8080/tcp | ||
- name: API 빌드 파일 복사 | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
source: "raisedragon-api-0.0.1-SNAPSHOT.jar" | ||
target: "/home/ec2-user" | ||
|
||
- name: API EC2 인스턴스 접속 및 애플리케이션 실행 | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.EC2_HOST }} | ||
username: ${{ secrets.EC2_USERNAME }} | ||
key: ${{ secrets.EC2_KEY }} | ||
script: | | ||
sudo cd /home/ec2-user | ||
sudo ./operate.sh |