Skip to content

Commit

Permalink
Update cicd.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
miiiinju1 authored Aug 26, 2024
1 parent 0e170bf commit a47d4a7
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions .github/workflows/cicd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down Expand Up @@ -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:
Expand All @@ -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
Expand Down

0 comments on commit a47d4a7

Please sign in to comment.