-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: remove cd from execution command
fix: ec2 target directory fix: fix host key verification failed <- add remote server to known hosts refactor: rename springboot action names fix: add ssh script to run springboot app & add comments
- Loading branch information
1 parent
1268060
commit 21f7549
Showing
2 changed files
with
17 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Springboot CI | ||
name: Springboot CI on PR | ||
|
||
on: | ||
pull_request: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: Springboot CI | ||
name: Springboot CI on Push | ||
|
||
on: | ||
push: | ||
|
@@ -25,24 +25,34 @@ jobs: | |
distribution: 'temurin' | ||
cache: gradle | ||
|
||
# Build & Test | ||
- name: Grant execute permission for gradlew | ||
run: chmod +x gradlew | ||
- name: Build with Gradle | ||
run: ./gradlew clean build | ||
- name: Test with Gradle | ||
run: ./gradlew test | ||
|
||
- name: Set up SSH | ||
# Setup SSH | ||
- name: Set up SSH agent with private key | ||
uses: webfactory/[email protected] | ||
with: | ||
ssh-private-key: ${{ secrets.SPRINGBOOT_EC2_SSH_KEY }} | ||
- name: Add remote server to known hosts | ||
run: | | ||
mkdir -p ~/.ssh | ||
ssh-keyscan -H ${{ secrets.SPRINGBOOT_HOST_DNS }} >> ~/.ssh/known_hosts | ||
# Deploy | ||
- name: SCP jar file to server | ||
run: | | ||
scp *jar ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }}:~/\ | ||
scp *jar ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }}:\ | ||
${{ secrets.SPRINGBOOT_TARGET_DIR }} | ||
working-directory: ./springboot/build/libs | ||
- name: Execute remote commands | ||
run: | | ||
ssh ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }}\ | ||
"fuser -k 8080/tcp" | ||
ssh ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }}\ | ||
ssh -v ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }} \ | ||
"fuser -k 8080/tcp || true" | ||
ssh -v ${{ secrets.SPRINGBOOT_USERNAME }}@${{ secrets.SPRINGBOOT_HOST_DNS }} \ | ||
"sudo nohup /usr/bin/java -jar ${{ secrets.SPRINGBOOT_TARGET_DIR }}/*.jar\ | ||
> {{ secrets.SPRINGBOOT_TARGET_DIR }}/app.log 2>&1 &" |