Skip to content

[Refactor] 로깅 추가 #54

[Refactor] 로깅 추가

[Refactor] 로깅 추가 #54

Workflow file for this run

name: CI/CD using docker & git actions
# 해당 브랜치에 push가 되었을 때 실행
on:
push:
branches: [ "main" ]
jobs:
CI-CD:
runs-on: ubuntu-latest
steps:
# JDK setting - github actions에서 사용할 JDK 설정 (프로젝트나 AWS의 java 버전과 달라도 무방)
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# application.properties 생성
- name: make application.properties
if: contains(github.ref, 'main')
run: |
mkdir ./src/main/resources
cd ./src/main/resources
touch ./application.properties
echo "${{ secrets.APPLICATION }}" > ./application.properties # github actions에서 설정한 값을 application.properties 파일에 쓰기
# gradle build
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew clean build -x test
- name: docker login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# 도커 이미지 생성 & 도커 허브에 이미지 푸시
- name: Docker build & push
run: |
docker build -f Dockerfile -t ${{ secrets.DOCKER_USERNAME }}/bjj:latest .
docker push ${{ secrets.DOCKER_USERNAME }}/bjj:latest
# 도커 이미지 배포
- name: Deploy docker image
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST}}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
key: ${{ secrets.SERVER_KEY }}
script_stop: true
script: |
sh bjj/deploy-bjj.sh