Skip to content

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

chore: 배포 스크립트 수정

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

Workflow file for this run

name: Build and Deploy
on:
push:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'
- name: create application-secret.yml
run: |
# application-secret.yml 파일 생성
touch ./src/main/resources/application-secret.yml
# GitHub-Actions 에서 설정한 값을 application-secret.yml 파일에 쓰기
echo "${{ secrets.SECRET }}" > ./src/main/resources/application-secret.yml
- name: Grant execute permission for Gradle wrapper
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build -x test
- name: Create SSH key file
env:
SCP_KEY: ${{ secrets.KEY }}
run: |
echo "${{ secrets.KEY }}" > scp_key.pem
chmod 600 scp_key.pem
- name: Copy JAR to EC2
env:
SCP_USER: ${{ secrets.USER }}
SCP_HOST: ${{ secrets.HOST }}
SCP_PATH: ${{ secrets.PATH }}
run: |
scp -v -o StrictHostKeyChecking=no -i scp_key.pem ./build/libs/*.jar $SCP_USER@$SCP_HOST:$SCP_PATH
EOF
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.KEY }}
script: |
cd ${{ secrets.PATH }}
nohup java -jar *.jar > app.log 2>&1 &
EOF