[fix] ssl 키 보관 장소 수정 #160
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: | |
tags: | |
- '[0-9]+.[0-9]+.[0-9]+' | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
# Checkout & Secret yml create | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- run: | | |
mkdir -p ./src/main/resources/secret | |
echo "#!/bin/sh" > ./deploy.sh | |
echo "echo 애플리케이션 pid 확인" >> ./deploy.sh | |
echo "CURRENT_PID=\$(jps | grep ${{ secrets.JAVA_APPLICATION_NAME }} | awk '{print \$1}')" >> ./deploy.sh | |
echo "if [ -z \$CURRENT_PID ]; then" >> ./deploy.sh | |
echo " echo 애플리케이션 없음" >> ./deploy.sh | |
echo "else" >> ./deploy.sh | |
echo " echo 애플리케이션 pid=\$CURRENT_PID" >> ./deploy.sh | |
echo " kill -9 \$CURRENT_PID" >> ./deploy.sh | |
echo " sleep 1" >> ./deploy.sh | |
echo "fi" >> ./deploy.sh | |
echo "echo 애플리케이션 배포" >> ./deploy.sh | |
echo "java -Dspring.profiles.active=release -jar ~/app/${{ secrets.JAVA_APPLICATION_NAME }}*.jar > /dev/null 2>&1 &" >> ./deploy.sh | |
echo "${{ secrets.MONGO_INFO }}" > ./src/main/resources/secret/mongo-info.yml | |
echo "${{ secrets.FRONT_INFO }}" > ./src/main/resources/secret/front-info.yml | |
echo "${{ secrets.SLACK_INFO }}" > ./src/main/resources/secret/slack-info.yml | |
echo "${{ secrets.JWT_INFO }}" > ./src/main/resources/secret/jwt-info.yml | |
echo "${{ secrets.OAUTH_INFO }}" > ./src/main/resources/secret/oauth-info.yml | |
echo "${{ secrets.SSL_INFO }}" > ./src/main/resources/secret/ssl-info.yml | |
echo "${{ secrets.OBJECTSTORAGE_INFO }}" > ./src/main/resources/secret/objectstorage-info.yml | |
# Update Submodule - Protocol Buffer | |
- name: Submodule Update | |
run: git submodule update --init --remote | |
# Project JDK 17 setting | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: 17 | |
distribution: temurin | |
cache: maven | |
# main Branch Build with Maven | |
- name: Build with Maven | |
run: mvn -B package --file pom.xml | |
# make release artifact | |
- name: Add artifacts to publish to the deploy folder | |
run: | | |
mkdir -p ./deploy | |
cp -r ./target/*.jar ./deploy | |
cp -r ./deploy.sh ./deploy | |
# Upload release artifact | |
- name: Upload release artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: release-artifact | |
path: ./deploy | |
deploy: | |
needs: build | |
runs-on: ubuntu-20.04 | |
steps: | |
# Download release artifact | |
- name: Download artifact jar | |
uses: actions/download-artifact@v2 | |
with: | |
name: release-artifact | |
# Transfer release artifact to NCloud | |
- name: Transfer Deploy Release jar using SCP | |
uses: appleboy/scp-action@master | |
with: | |
username: ${{ secrets.NCP_USERNAME }} | |
host: ${{ secrets.NCP_HOST }} | |
password: ${{ secrets.NCP_PASSWORD }} | |
port: ${{ secrets.NCP_PORT }} | |
source: "*" | |
target: "~/app" | |
# Exec Deploy Script | |
- name: Execute Server Deploy Script | |
uses: appleboy/ssh-action@master | |
with: | |
username: ${{ secrets.NCP_USERNAME }} | |
host: ${{ secrets.NCP_HOST }} | |
password: ${{ secrets.NCP_PASSWORD }} | |
port: ${{ secrets.NCP_PORT }} | |
script_stop: true | |
script: chmod -R +x ~/app && sh ~/app/deploy.sh |