-
Notifications
You must be signed in to change notification settings - Fork 0
73 lines (63 loc) · 1.75 KB
/
CI-CD.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: CI/CD
env:
SECRET_CODE : ${{ secrets.SECRET_CODE}}
on:
push:
branches: ["main"]
jobs:
CI:
runs-on: ubuntu-22.04
steps:
- name: 체크아웃
uses: actions/checkout@v3
# JDK 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: make application.yml
run: |
mkdir -p ./src/main/resources
cd ./src/main/resources
touch ./application.yml
echo "${{ secrets.APPLICATION_DEV }}" > ./application.yml
shell: bash
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build -x test
shell: bash
- name: Docker Buildx
uses: docker/[email protected]
- name: Docker Login
uses: docker/[email protected]
with:
username: ${{ secrets.DOCKER_LOGIN_USERNAME }}
password: ${{ secrets.DOCKER_LOGIN_ACCESSTOKEN }}
- name: Docker build & push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: daruda241221/daruda
CD:
needs: CI
runs-on: ubuntu-22.04
steps:
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.DOCKER_USERNAME }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
LOG_DIR="/home/ubuntu/daruda_log"
if [ ! -d "$LOG_DIR" ]; then
mkdir -p "$LOG_DIR"
echo "로그 폴더 생성 완료: $LOG_DIR"
fi
# 기존 배포 스크립트 실행
cd ~
./deploy.sh