Merge pull request #87 from Team-UMC/feature/#86/schedule-dummy-data #53
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: UMC Service Dev CI/CD | |
on: | |
push: | |
branches: [ "develop" ] | |
jobs: | |
build-docker-image: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
# 1. Java 17 세팅 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: make application.yml | |
run: | | |
# create application.yml | |
cd ./src/main | |
cd ./resources | |
# application.yml 파일 생성하기 | |
touch ./application.yml | |
# Secrets에 저장한 값을 application.yml 파일에 쓰기 | |
echo "${{ secrets.DEV_YML }}" >> ./application.yml | |
shell: bash | |
# 2. Spring Boot 애플리케이션 빌드 | |
- name: Build with Gradle | |
run: | | |
chmod +x ./gradlew | |
./gradlew clean build -x test | |
# 3. Docker 이미지 빌드 | |
- name: docker image build | |
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}-dev . | |
# 4. DockerHub 로그인 | |
- name: docker login | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
# 5. Docker Hub 이미지 푸시 | |
- name: docker Hub push | |
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}-dev | |
# 6. 서버에서 실행 | |
- name: Deploy to server | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ubuntu | |
key: ${{ secrets.KEY }} | |
port: 22 | |
script: | | |
cd / | |
sudo docker-compose -f docker-compose.dev.yml down | |
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPO }}-dev | |
sudo docker-compose -f docker-compose.dev.yml up -d | |
sudo docker image prune -f |