-
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.
Browse files
Browse the repository at this point in the history
#318 cicd 설정
- Loading branch information
Showing
5 changed files
with
118 additions
and
94 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,23 @@ | ||
name: build | ||
|
||
on: | ||
pull_request: | ||
branches: [ "develop" ] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build and Test | ||
run: ./gradlew build -x test |
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,58 @@ | ||
name: deploy | ||
|
||
on: | ||
push: | ||
branches: [ "develop" ] | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Gradle Caching | ||
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: Set up JDK 11 | ||
uses: actions/setup-java@v1 | ||
with: | ||
java-version: 11 | ||
|
||
- run: touch ./src/main/resources/application.yml | ||
- run: echo "${{ secrets.APPLICATION_SECRET }}" > ./src/main/resources/application.yml | ||
- run: cat ./src/main/resources/application.yml | ||
|
||
- name: Grant execute permission for gradlew | ||
run: chmod +x ./gradlew | ||
shell: bash | ||
|
||
- name: Build and no Test | ||
run: ./gradlew build -x test | ||
|
||
- name: Docker build & push to dev | ||
run: | | ||
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | ||
docker build -t ${{ secrets.DOCKER_USERNAME }}/ice . | ||
docker push ${{ secrets.DOCKER_USERNAME }}/ice | ||
- name: Deploy to dev | ||
uses: appleboy/ssh-action@master | ||
id: deploy-dev | ||
with: | ||
host: ${{ secrets.HOST_DEV }} | ||
username: ${{ secrets.USERNAME }} | ||
port: 22 | ||
key: ${{ secrets.PRIVATE_KEY }} | ||
script: | | ||
sudo docker stop $(docker ps -a -q) | ||
sudo docker rm $(docker ps -a -q) | ||
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/ice | ||
sudo docker run -d -p 8080:8080 ${{ secrets.DOCKER_USERNAME }}/ice | ||
sudo docker image prune -f |
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,15 @@ | ||
version: 0.0 | ||
os: linux | ||
|
||
files: | ||
- source: / | ||
destination: /home/ubuntu/ice | ||
permissions: | ||
- object: /home/ubuntu/ice/ | ||
owner: ubuntu | ||
group: ubuntu | ||
hooks: | ||
AfterInstall: | ||
- location: scripts/deploy.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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bash | ||
|
||
REPOSITORY=/home/ubuntu/ice | ||
cd $REPOSITORY | ||
|
||
APP_NAME=ice | ||
JAR_NAME=$(ls $REPOSITORY/build/libs/ | grep 'SNAPSHOT.jar' | tail -n 1) | ||
JAR_PATH=$REPOSITORY/build/libs/$JAR_NAME | ||
|
||
CURRENT_PID=$(pgrep -f $APP_NAME) | ||
|
||
if [ -z $CURRENT_PID ] | ||
then | ||
echo "> 종료할 애플리케이션이 없습니다." | ||
else | ||
echo "> kill -9 $CURRENT_PID" | ||
kill -15 $CURRENT_PID | ||
sleep 5 | ||
fi | ||
|
||
echo "> Deploy - $JAR_PATH " | ||
nohup java -jar $JAR_PATH > /dev/null 2> /dev/null < /dev/null & |
This file was deleted.
Oops, something went wrong.