Skip to content

Commit

Permalink
feat(github) : cd.yml 작성
Browse files Browse the repository at this point in the history
  • Loading branch information
Woongbin06 committed Apr 15, 2024
1 parent d0db295 commit 7154b69
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Java CD with Gradle

on:
push:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest
permissions:
contents: read

steps:
- uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'

- name: Setup Gradle
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5

- name: Build with Gradle Wrapper
run: ./gradlew build

- name: Deploy to server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_NAME }}
password: ${{ secrets.SERVER_PASSWORD }}
source: ${{ SOURCE_PATH }}
target: ${{ DIST_PATH }}

- name: Execute jar file
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_NAME }}
password: ${{ secrets.SERVER_PASSWORD }}
script: |
PID=$(lsof -ti:8080)
if [ -n "$PID" ]; then
kill $PID
nohup java -jar $${{ secrets.JAR_FILE }}

0 comments on commit 7154b69

Please sign in to comment.