-
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.
- Loading branch information
Showing
1 changed file
with
13 additions
and
3 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 |
---|---|---|
|
@@ -3,7 +3,7 @@ on: | |
push: | ||
branches: [ "cicd-test" ] | ||
env: | ||
JAR_FILE: logbat.jar | ||
JAR_FILE_PATTERN: "*.jar" | ||
BASTION_HOST_IP: ${{ secrets.BASTION_HOST_IP }} | ||
BACKEND_HOST_IP: ${{ secrets.BACKEND_HOST_IP }} | ||
|
||
|
@@ -40,6 +40,16 @@ jobs: | |
cd logbat | ||
./gradlew clean bootJar -x test | ||
- name: Verify JAR file exists | ||
run: | | ||
cd logbat/build/libs | ||
echo "Checking for JAR files..." | ||
ls -la | ||
if [ -z "$(ls ${{ env.JAR_FILE_PATTERN }})" ]; then | ||
echo "Error: No JAR files found!" | ||
exit 1 | ||
fi | ||
- name: Start SSH Agent and Add Bastion Key | ||
uses: webfactory/[email protected] | ||
with: | ||
|
@@ -48,11 +58,11 @@ jobs: | |
- name: Add Target Server Key to SSH Agent | ||
run: echo "${{ secrets.PRIVATE_SSH_SECRET_KEY }}" | ssh-add - | ||
|
||
- name: SCP JAR file to EC2 via Bastion | ||
- name: SCP JAR files to EC2 via Bastion | ||
run: | | ||
cd logbat/build/libs | ||
scp -o StrictHostKeyChecking=no -o ProxyCommand="ssh -W %h:%p -o StrictHostKeyChecking=no ubuntu@${{ secrets.BASTION_HOST_IP }}" \ | ||
logbat.jar ubuntu@${{ secrets.BACKEND_HOST_IP }}:/home/ubuntu/${{ env.JAR_FILE }} | ||
${{ env.JAR_FILE_PATTERN }} ubuntu@${{ secrets.BACKEND_HOST_IP }}:/home/ubuntu/ | ||
deploy: | ||
name: Deploy to EC2 | ||
|