충남대 BE_윤정훈 6주차 과제 (2단계 & 3단계) #20
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: JAVA CI with GRADLE | |
on: | |
push: | |
branches: [ "yunjunghun0116" ] | |
pull_request: | |
branches: [ "yunjunghun0116" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 시작 | |
uses: actions/checkout@v4 | |
- name: JDK 21로 실행 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
cache: gradle | |
- name: gradle 생성 | |
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 | |
- name: 설정파일 생성 | |
run: | | |
echo "${{ secrets.APPLICATION_PROPERTIES }}" >> ./src/main/resources/application.properties | |
cat ./src/main/resources/application.properties | |
- name: gradlew 권한 추가 | |
run: chmod +x gradlew | |
- name: 빌드 작업 | |
run: ./gradlew build | |
- name: 테스트 작업 | |
run: ./gradlew test | |
- name: 서버에 배포하기 | |
env: | |
SSH_KEY: ${{ secrets.SSH_KEY }} | |
DEPLOY_SERVER: ${{ secrets.DEPLOY_SERVER }} | |
DEPLOY_USER: ${{ secrets.DEPLOY_USER }} | |
run: | | |
echo "$SSH_KEY" > key.pem | |
chmod 400 key.pem | |
scp -o StrictHostKeyChecking=no -i key.pem build/libs/*.jar $DEPLOY_USER@$DEPLOY_SERVER:~/spring-gift-point/build/libs/ | |
scp -o StrictHostKeyChecking=no -i key.pem ./src/main/resources/application.properties $DEPLOY_USER@$DEPLOY_SERVER:~/spring-gift-point/src/main/resources/application.properties | |
ssh -o StrictHostKeyChecking=no -i key.pem $DEPLOY_USER@$DEPLOY_SERVER " | |
sudo lsof -t -i:8080 | xargs -r sudo kill -9 | |
nohup java -jar ~/spring-gift-point/build/libs/spring-gift-0.0.1-SNAPSHOT.jar > /dev/null 2>&1 & | |
exit | |
" && echo "스프링 프로젝트가 서버에서 정상적으로 돌아가고 있습니다." | |
dependency-submission: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up JDK 21 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '21' | |
distribution: 'temurin' | |
- name: Generate and submit dependency graph | |
uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 |