Skip to content

Commit

Permalink
Update server2-cd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
redcarrot1 authored May 25, 2024
1 parent 389e404 commit d44be84
Showing 1 changed file with 2 additions and 70 deletions.
72 changes: 2 additions & 70 deletions .github/workflows/server2-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,62 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'

- name: Gradle Caching
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Setup redis
uses: shogo82148/[email protected]
with:
redis-version: 6.2.0
redis-port: 6379
auto-start: true

- name: injection application.yml
run: |
touch src/main/resources/application-prod.yml
touch src/main/resources/application-dev.yml
touch src/main/resources/application-test.yml
touch src/main/resources/application-prod-log.properties
touch src/main/resources/application-dev-log.properties
echo "${{ secrets.PROD_YML }}" > src/main/resources/application-prod.yml
echo "${{ secrets.DEV_YML }}" > src/main/resources/application-dev.yml
echo "${{ secrets.TEST_YML }}" > src/main/resources/application-test.yml
echo "${{ secrets.DEV_LOG_PROPERTIES }}" > src/main/resources/application-dev-log.properties
echo "${{ secrets.PROD_LOG_PROPERTIES }}" > src/main/resources/application-prod-log.properties
shell: bash

- name: Grant execute permission for gradlew
run: chmod +x ./gradlew

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

- name: Deliver JAR File
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST2 }}
username: ${{ secrets.SSH_USERNAME2 }}
password: ${{ secrets.SSH_PASSWORD2 }}
port: ${{ secrets.SSH_PORT2 }}
timeout: "60s"
source: "build/libs/*.jar"
target: "source"
rm: true


- name: Deploy
uses: appleboy/ssh-action@master
with:
Expand All @@ -72,17 +17,4 @@ jobs:
password: ${{ secrets.SSH_PASSWORD2 }}
port: ${{ secrets.SSH_PORT2 }}
script: |
SOURCE_DIR=source/build/libs
FILE_NAME=`find $SOURCE_DIR/*.jar -printf "%f\n"`
PID=$(sudo lsof -Fp -i TCP:8080 | grep -Po 'p[0-9]+' | grep -Po '[0-9]+')
if [ -z "$PID" ]; then
echo "#### THERE IS NO PROCESS ####"
else
echo "#### KILL $PID ####"
sudo kill -9 $PID
fi
echo "#### RUN $SOURCE_DIR/$FILE_NAME ####"
sudo nohup java -jar -Dspring.profiles.active="prod" $SOURCE_DIR/$FILE_NAME 1>$SOURCE_DIR/stdout.out 2>$SOURCE_DIR/stderr.out 2>&1 &
echo "test" > ~/tt.txt

0 comments on commit d44be84

Please sign in to comment.