Thanks to visit codestin.com
Credit goes to github.com

Skip to content

공지수정

공지수정 #50

Workflow file for this run

name: Deploy to EC2
on:
push:
branches: [ "main" ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout source code
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Grant execute permission to gradlew
run: chmod +x ./gradlew
- name: Build .jar (excluding tests)
run: ./gradlew clean build -x test
- name: Install rsync
run: sudo apt-get update && sudo apt-get install -y rsync
- name: Create SSH Key file
run: |
echo "${{ secrets.EC2_SSH_KEY }}" > outline-key.pem
chmod 600 outline-key.pem
- name: Upload .jar to EC2 with rsync
run: |
rsync -avz -e "ssh -i outline-key.pem -o StrictHostKeyChecking=no" ./build/libs/outline-0.0.1-SNAPSHOT.jar ubuntu@${{ secrets.EC2_HOST }}:~/outline/build/libs/
- name: Restart docker-compose on EC2
run: |
ssh -i outline-key.pem -o StrictHostKeyChecking=no ubuntu@${{ secrets.EC2_HOST }} << 'EOF'
cd ~/outline
sudo docker-compose down
sudo docker-compose up -d --build
EOF
- name: Delete SSH Key
run: rm -f outline-key.pem