Skip to content

chore: 배포 스크립트 수정 #1

chore: 배포 스크립트 수정

chore: 배포 스크립트 수정 #1

Workflow file for this run

name: deploy
on:
push:
branches:
- '**'
permissions:
contents: read
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: make application-secret.yml
run: |
cd ./Team6-Drive || exit 1
touch ./src/main/resources/application-secret.yml
echo "${{ secrets.SECRET }}" > ./src/main/resources/application-secret.yml
shell: bash
- name: Build with Gradle
run: |
cd ./Team6-Drive || exit 1
chmod +x gradlew
./gradlew build -x test
- name: Create SSH key file
env:
SSH_KEY: ${{ secrets.KEY }}
run: |
echo "$SSH_KEY" > ssh_key.pem
chmod 600 ssh_key.pem
- name: Copy JAR to EC2 and Restart Application
env:
SSH_USER: ${{ secrets.USER }}
SSH_HOST: ${{ secrets.HOST }}
SSH_PATH: ${{ secrets.PATH }}
run: |
scp -o StrictHostKeyChecking=no -i ssh_key.pem ./Team6-Drive/build/libs/*.jar $SSH_USER@$SSH_HOST:$SSH_PATH
ssh -o StrictHostKeyChecking=no -i ssh_key.pem $SSH_USER@$SSH_HOST << EOF
cd $SSH_PATH
pkill -f '*.jar'
nohup java -jar *.jar > app.log 2>&1 &
EOF