chore: 배포 스크립트 수정 #5
Workflow file for this run
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: 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: | | |
# application-database.yml 파일 생성 | |
touch ./src/main/resources/application-secret.yml | |
# GitHub-Actions 에서 설정한 값을 application-database.yml 파일에 쓰기 | |
echo "${{ secrets.SECRET }}" > ./src/main/resources/application-secret.yml | |
shell: bash | |
- name: Build with Gradle | |
run: | | |
chmod +x gradlew | |
# Run Gradle build | |
./gradlew 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 | |
- 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 & |