Skip to content

Fis/#139 LinkedList 자료구조 개선 (#141) #62

Fis/#139 LinkedList 자료구조 개선 (#141)

Fis/#139 LinkedList 자료구조 개선 (#141) #62

Workflow file for this run

name: cicd pipeline
on:
push:
branches: [ "dev" ]
env:
JAR_FILE: logbat.jar
BASTION_HOST_IP: ${{ secrets.BASTION_HOST_IP }}
BACKEND_HOST_IP: ${{ secrets.BACKEND_HOST_IP }}
permissions:
contents: read
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Liberica JDK 17
uses: actions/setup-java@v3
with:
distribution: 'corretto'
java-version: '17'
- name: Cleanup application.yml
run: |
cd logbat
rm -f src/main/resources/application.yml
- name: Create application-dev.yml from GitHub Secret
run: |
cd logbat
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
- name: Build with Gradle
env:
ORG_GRADLE_OPTS: "-Duser.timezone=Asia/Seoul"
run: |
cd logbat
./gradlew clean bootJar -x test
- name: Rename JAR file to logbat.jar
run: |
cd logbat/build/libs
JAR_FILE=$(ls *.jar)
if [ -z "$JAR_FILE" ]; then
echo "Error: No JAR files found!"
exit 1
fi
mv "$JAR_FILE" logbat.jar
echo "Renamed $JAR_FILE to logbat.jar"
- name: Start SSH Agent and Add Bastion Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.BASTION_SSH_SECRET_KEY }}
- 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
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/logbat.jar
deploy:
name: Deploy to EC2
needs: build-and-push
runs-on: ubuntu-latest
steps:
- name: Start SSH Agent and Add Bastion Key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.BASTION_SSH_SECRET_KEY }}
- name: Add Target Server Key to SSH Agent
run: echo "${{ secrets.PRIVATE_SSH_SECRET_KEY }}" | ssh-add -
- name: Connect to Bastion and Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no -A ubuntu@${{ secrets.BASTION_HOST_IP }} \
"ssh -o StrictHostKeyChecking=no ubuntu@${{ secrets.BACKEND_HOST_IP }} 'bash -l /home/ubuntu/deploy.sh'"