Skip to content

[feat] Schedular Sample (#31) #19

[feat] Schedular Sample (#31)

[feat] Schedular Sample (#31) #19

Workflow file for this run

name: Picasso CI/CD
on:
push:
branches: [ "dev", "main" ]
permissions:
contents: read
jobs:
build:
name: Picasso CI/CD
runs-on: ubuntu-latest
steps:
- name: Github Action Version Checkout
uses: actions/checkout@v2
- name: Setup jdk-17
uses: actions/setup-java@main
with:
java-version: 17
distribution: 'zulu'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: Test with Gradle
run: ./gradlew test
- name: Build with Gradle
run: ./gradlew build
- name: Move App.jar
run : mv ./Api/build/libs/app.jar ./
# Proxy Server Connect with SSH
# scp로 proxy server에 build된 Jar 파일을 보낸다
# jar 파일을 실행한다. 이 때 storage에 대한 VM Option을 추가하여 실행한다.
- name: Transfer BuildFile Git Actions To ApplicationServer
uses: appleboy/scp-action@master
with:
proxy_host: ${{ secrets.NCP_PROXY_HOST }}
proxy_username: root
proxy_key: ${{ secrets.NCP_PEM }}
proxy_port: 2222
host: ${{ secrets.NCP_APP_HOST }}
username: root
key: ${{ secrets.NCP_PEM }}
port: 22
source: app.jar
target: /var/app
- name: Run Application
uses: appleboy/ssh-action@master
with:
proxy_host: ${{ secrets.NCP_PROXY_HOST }}
proxy_username: root
proxy_key: ${{ secrets.NCP_PEM }}
proxy_port: 2222
host: ${{ secrets.NCP_APP_HOST }}
username: root
key: ${{ secrets.NCP_PEM }}
port: 22
script: |
CURRENT_PID=$(pgrep -fl app | grep java | awk '{print $1}' )
if [ -z "$CURRENT_PID" ]; then
echo "> no applcation named java is running"
else
echo "> kill -9 java"
kill -9 $CURRENT_PID
sleep 5
fi
nohup java -jar -Dspring.profiles.active=dev -Dnaver.storage.access-key=${{ secrets.ACCESS_KEY }} -Dnaver.storage.secret-key=${{ secrets.SECRET_KEY }} /var/app/app.jar > nohup.log 2> nohup.err < /dev/null &