build: 빌드 과정에서 api 문서화 제거 #43
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
# This workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time | |
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle | |
name: deploy | |
on: | |
push: | |
branches: [ "main" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup MySQL | |
run: | | |
sudo docker run -d -p 20000:3306 -e MYSQL_DATABASE=busan -e MYSQL_ROOT_PASSWORD=password mysql:8.0.23 | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Build with Gradle | |
uses: gradle/[email protected] | |
with: | |
arguments: clean build | |
- name: SCP to prod server | |
uses: appleboy/scp-action@master | |
with: | |
username: ubuntu | |
host: ${{ secrets.HOST }} | |
key: ${{ secrets.PRIVATE_KEY }} | |
source: "build/libs/*-SNAPSHOT.jar" | |
target: "/home/ubuntu/server" | |
strip_components: 2 | |
- name: Deploy | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.HOST }} | |
username: 'ubuntu' | |
key: ${{ secrets.PRIVATE_KEY }} | |
script: | | |
cd /home/ubuntu/server | |
if sudo lsof -i :8080; | |
then | |
echo "Port 8080 is already in use. Killing the process..." | |
sudo lsof -i :8080 | awk 'NR!=1 {print $2}' | sudo xargs kill -9 | |
fi | |
while lsof -i :8080 | |
do | |
echo "Wait for killing prior process..." | |
sleep 1 | |
done | |
echo "Start Spring..." | |
sudo nohup java -jar -Dspring.profiles.active=prod -Duser.timezone=Asia/Seoul busan-0.0.1-SNAPSHOT.jar > nohup.out 2> nohup.err < /dev/null & | |
echo "Finished!" | |
- name: Docker build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} . | |
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} |