Skip to content

Commit

Permalink
feat: self-hosted deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
ay-eonii committed Jul 16, 2024
1 parent 803e65a commit 19630eb
Showing 1 changed file with 52 additions and 25 deletions.
77 changes: 52 additions & 25 deletions .github/workflows/leets-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,10 @@ run-name: Running
on:
push:
branches:
- main
- dev
- 'releases/**'

env:
AWS_REGION: ap-northeast-2
AWS_S3_BUCKET: gitactionbucket
AWS_CODE_DEPLOY_APPLICATION: cicd-test-cd
AWS_CODE_DEPLOY_GROUP: cicd-test-cd-group
APPLICATION: ${{ secrets.APPLICATION }}
WORKING_DIRECTORY: ./

Expand Down Expand Up @@ -38,26 +34,57 @@ jobs:
- name: 프로젝트 빌드
run: ./gradlew clean build -x test

- name: DockerHub 로그인
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
deploy:
needs: build
runs-on: self-hosted
steps:
- name: change permission
run: |
sudo chown -R ubuntu:ubuntu /home/ubuntu/actions-runner/_work/jwp-shopping-order
- name: kill 8080 port if exist
run: |
CURRENT_PID=$(pgrep -f ${PROJECT_NAME}.*.jar)
if [ -z "$CURRENT_PID" ]; then
echo "> NONE\\n"
else
echo "> kill -9 ${CURRENT_PID}\\n"
kill -9 $CURRENT_PID
sleep 5
fi
- name: 도커 이미지 빌드 및 푸시
# 스프링 프로그램을 실행합니다
- name: deploy
run: |
docker build -t ayeonii/leets-be:latest .
docker push ayeonii/leets-be:latest
echo "> Deploy New Project$\\n"
JAR_NAME=$(ls -tr build/libs/*.jar | tail -n 1)
echo "> jar Name : $JAR_NAME\\n"
nohup java -jar $JAR_NAME &
- name: 배포
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_IP }}
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_IDENTITYFILE }}
port: ${{ secrets.REMOTE_PORT }}
script: |
cd server
docker compose -f docker-compose.yml down leets-be
docker compose -f docker-compose.yml pull leets-be
docker compose -f docker-compose.yml up -d leets-be
#
# - name: DockerHub 로그인
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
#
# - name: 도커 이미지 빌드 및 푸시
# run: |
# docker build -t ayeonii/leets-be:latest .
# docker push ayeonii/leets-be:latest
#
# - name: 배포
# uses: appleboy/ssh-action@master
# with:
# host: ${{ secrets.REMOTE_IP }}
# username: ${{ secrets.REMOTE_USER }}
# key: ${{ secrets.REMOTE_IDENTITYFILE }}
# port: ${{ secrets.REMOTE_PORT }}
# script: |
# cd server
# docker compose -f docker-compose.yml down leets-be
# docker compose -f docker-compose.yml pull leets-be
# docker compose -f docker-compose.yml up -d leets-be

0 comments on commit 19630eb

Please sign in to comment.