Merge branch 'main' of https://github.com/ne-o-rdinary/back #1
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
name: CI/CD Deployment | |
on: | |
push: | |
branches: | |
- main # main 브랜치에 푸시될 때 트리거 | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Build project | |
run: ./gradlew clean build | |
- name: Copy JAR to remote server | |
env: | |
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
run: | | |
mkdir -p ~/.ssh | |
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
echo -e "Host mykeyhost\n User ubuntu\n HostName 13.209.198.1\n IdentityFile ~/.ssh/id_rsa\n StrictHostKeyChecking no" > ~/.ssh/config | |
scp build/libs/demo-0.0.1-SNAPSHOT.jar mykeyhost:~/ | |
- name: Deploy application | |
run: | | |
ssh mykeyhost << 'EOF' | |
sudo pkill -f 'java -jar' || true | |
sudo nohup java -jar ~/demo-0.0.1-SNAPSHOT.jar --server.port=443 > app.log 2>&1 & | |
EOF |