Skip to content

Commit

Permalink
Update deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoon0221 authored Nov 23, 2024
1 parent 83a4e7a commit bf3d153
Showing 1 changed file with 31 additions and 28 deletions.
59 changes: 31 additions & 28 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Build project
run: ./gradlew clean build

- name: Copy JAR to remote server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo -e "Host mykeyhost\n User ubuntu\n HostName 13.209.198.1\n IdentityFile ~/.ssh/id_rsa\n StrictHostKeyChecking no" > ~/.ssh/config
scp build/libs/demo-0.0.1-SNAPSHOT.jar mykeyhost:~/
- name: Deploy application
run: |
ssh mykeyhost << 'EOF'
sudo pkill -f 'java -jar' || true
sudo nohup java -jar ~/demo-0.0.1-SNAPSHOT.jar --server.port=443 > app.log 2>&1 &
EOF
- name: Checkout code
uses: actions/checkout@v3

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

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

- name: Build project
run: ./gradlew clean build

- name: Copy JAR to remote server
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
echo -e "Host mykeyhost\n User ubuntu\n HostName 13.209.198.1\n IdentityFile ~/.ssh/id_rsa\n StrictHostKeyChecking no" > ~/.ssh/config
scp build/libs/demo-0.0.1-SNAPSHOT.jar mykeyhost:~/
- name: Deploy application
run: |
ssh mykeyhost << 'EOF'
sudo pkill -f 'java -jar' || true
sudo nohup java -jar ~/demo-0.0.1-SNAPSHOT.jar --server.port=443 > app.log 2>&1 &
EOF

0 comments on commit bf3d153

Please sign in to comment.