-
Notifications
You must be signed in to change notification settings - Fork 4
71 lines (63 loc) · 2.14 KB
/
dev-cd.yml
File metadata and controls
71 lines (63 loc) · 2.14 KB
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
# github repository actions 페이지에 나타날 이름
name: CD to dev using github actions
# event trigger
# develop 브랜치에 pull_request가 닫혔을 때 실행
on:
pull_request:
types: [ closed ]
branches: [ "develop" ]
permissions:
contents: read
jobs:
DEV-CD:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
env:
DOCKER_CLIENT_TIMEOUT: 600
COMPOSE_HTTP_TIMEOUT: 600
steps:
- uses: actions/checkout@v4
- name: 'Set up jdk'
uses: actions/setup-java@v4.7.0
with:
java-version: '17'
distribution: 'temurin' # https://github.com/actions/setup-java
- run: touch ./Dockerfile
- run: echo "${{ secrets.DEV_DOCKERFILE }}" > ./Dockerfile
# gradle caching - 빌드 시간 향상
- name: Gradle Caching
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
## gradle build
- name: Build with Gradle
run: |
chmod +x ./gradlew
./gradlew build -x test
## docker build & push to production
- name: Docker build & push to dev
run: |
docker login clap.kr-central-2.kcr.dev -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }}
docker build -t ${{ secrets.DOCKER_REPO }} .
docker push ${{ secrets.DOCKER_REPO }}
## deploy to dev
- name: Deploy to prod
uses: appleboy/ssh-action@master
id: deploy
with:
host: ${{ secrets.DEV_HOST }}
username: ${{ secrets.DEV_HOST_USERNAME }}
key: ${{ secrets.DEV_HOST_KEY }}
port: ${{ secrets.DEV_HOST_PORT }}
script: |
docker rm -f taskflow
docker image rm ${{ secrets.DOCKER_REPO }} -f
docker run --name taskflow -d -p 9090:9090 \
--env-file /home/ubuntu/.env \
${{ secrets.DOCKER_REPO }} \
--restart on-failure