Skip to content

fix: gitignore ์ˆ˜์ • #8

fix: gitignore ์ˆ˜์ •

fix: gitignore ์ˆ˜์ • #8

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