Skip to content

Release 머지

Release 머지 #83

name: CLIMEET_DEPLOY
on:
push:
branches: ["main", "release"]
jobs:
build:
runs-on: ubuntu-latest
steps:
#체크아웃
- name: Checkout code
uses: actions/checkout@v3
# JDK 설치
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
#서브 모듈 접근
- name: Checkout repo
uses: actions/checkout@v3
with:
token: ${{ secrets.CLIMEET_ACTION_TOKEN }}
submodules: true
# 서브 모듈 변경 점 있으면 update
- name: Git Submodule Update
run: |
git submodule update --remote --recursive
# gradlew 권한 변경
- name: Grant execute permission for gradlew
run: chmod +x gradlew
# 빌드(test는 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x test
# Docker 이미지 빌드 (Main Branch)
- name: Docker 이미지 빌드 (Main Branch)
if: github.ref == 'refs/heads/main'
run: docker build --build-arg SPRING_PROFILE=prod -t gourderased/spring-project:latest .
# Docker 이미지 빌드 (Release Branch)
- name: Docker 이미지 빌드 (Release Branch)
if: github.ref == 'refs/heads/release'
run: docker build --build-arg SPRING_PROFILE=dev -t gourderased/spring-project:latest .
# DockerHub 로그인
- name: Docker - Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Docker Hub 이미지 푸시
- name: Docker Hub 퍼블리시
run: docker push gourderased/spring-project:latest
# Deploy to EC2 (Main Branch)
- name: Deploy to EC2 (Main Branch)
if: github.ref == 'refs/heads/main'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.MAIN_EC2_HOST }}
username: ubuntu
key: ${{ secrets.MAIN_SSH_KEY }}
script: |
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker pull gourderased/spring-project:latest
sudo docker run -d -p 8080:8080 --name climeet-prod-server -e SPRING_PROFILE=prod -e TZ=Asia/Seoul gourderased/spring-project:latest
# Deploy to EC2 (Release Branch)
- name: Deploy to EC2 (Release Branch)
if: github.ref == 'refs/heads/release'
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.RELEASE_EC2_HOST }}
username: ubuntu
key: ${{ secrets.RELEASE_SSH_KEY }}
script: |
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker pull gourderased/spring-project:latest
sudo docker run -d -p 8080:8080 --name climeet-dev-server -e SPRING_PROFILE=dev -e TZ=Asia/Seoul gourderased/spring-project:latest