Skip to content

fix/#109 PUT /skills/effects API 저장 오류 해결 #65

fix/#109 PUT /skills/effects API 저장 오류 해결

fix/#109 PUT /skills/effects API 저장 오류 해결 #65

name: CD with Gradle & Deploy
on:
pull_request:
types:
- closed
jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Set YML
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
find src
- name: Make Gradlew executable
run: chmod +x ./gradlew
- name: Build with Gradle
uses: gradle/gradle-build-action@67421db6bd0bf253fb4bd25b31ebb98943c375e1
with:
arguments: build
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: cicdsample
path: build/libs/game-0.0.1-SNAPSHOT.jar
deploy:
needs: if_merged
runs-on: ubuntu-latest
steps:
- name: Download build artifacts
uses: actions/download-artifact@v2
with:
name: cicdsample
path: build/libs/
- name: Deploy to EC2
run: |
echo "${{ secrets.SERVER_SSH_KEY }}" > private_key.pem
chmod 600 private_key.pem
scp -i private_key.pem -o StrictHostKeyChecking=no build/libs/game-0.0.1-SNAPSHOT.jar ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }}:/home/${{ secrets.SERVER_USERNAME }}/game.jar
ssh -i private_key.pem -o StrictHostKeyChecking=no ${{ secrets.SERVER_USERNAME }}@${{ secrets.SERVER_HOST }} "sudo lsof -ti:80 | xargs sudo kill -9; sudo nohup java -jar /home/${{ secrets.SERVER_USERNAME }}/game.jar > app.log 2>&1 &"
rm -f private_key.pem