Refactor: "Mapper 줄바꿈 수정" #54
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
name: Spring Gradle CI | |
on: #이벤트 | |
push: | |
branches: [ master ] | |
pull_request: | |
branches: [ master ] | |
jobs: #작업 | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# CI (NCP) | |
- name: Checkout code #코드 오류 검토 | |
uses: actions/checkout@v2 | |
- name: Set up JDK 11 #JAVA 설정 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Cache Gradle packages # GRADLE 패키징 | |
uses: actions/cache@v2 | |
with: | |
path: ~/.gradle/caches | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: ${{ runner.os }}-gradle | |
- name: Gradle Build without Tests #빌드 테스트 | |
run: | | |
cd Gserver | |
chmod +x ./gradlew | |
./gradlew build -x test | |
# CD (NCP) | |
- name: Install sshpass #SSH 업데이트 | |
run: sudo apt-get install sshpass | |
- name: Setup SSH Key #SSH 키 설정 | |
env: | |
PRIVATE_KEY: ${{ secrets.NCP_SERVER_KEY }} | |
run: | | |
echo "$PRIVATE_KEY" > private_key.pem | |
chmod 600 private_key.pem | |
- name: Pull Latest Code from Repository #최신 코드 PULL | |
env: | |
HOST: 101.101.161.237 | |
USER: root | |
GIT_DIR: /root/Gserver | |
run: | | |
sshpass -p 'yechan1460' ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST -p 2222 "cd $GIT_DIR && git pull" | |
- name: Build on Server with Gradle #Gradle 빌드 실행 | |
env: | |
HOST: 101.101.161.237 | |
USER: root | |
GRADLE_DIR: /root/Gserver/Gserver | |
run: | | |
sshpass -p 'yechan1460' ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST -p 2222 "cd $GRADLE_DIR && ./gradlew build -x test" | |
- name: Restart Java Application #Application 재시작 | |
env: | |
HOST: 101.101.161.237 | |
USER: root | |
JAR_DIR: build/libs/Gserver-0.0.1-SNAPSHOT.jar | |
run: | | |
sshpass -p 'yechan1460' ssh -o StrictHostKeyChecking=no -i private_key.pem $USER@$HOST -p 2222 "pkill -f java && nohup java -jar $JAR_DIR &" | |
- name: Cleanup SSH Key #SSH키 삭제 | |
run: rm -f private_key.pem |