-
Notifications
You must be signed in to change notification settings - Fork 3
87 lines (74 loc) · 2.72 KB
/
CI-CD Develop.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
name: Web Application Dev Server CI/CD
on:
push:
branches: [ "develop" ]
pull_request_target:
types: [labeled, closed]
jobs:
# safe tag에 대한 gradlew test && merged에 대한 gradlew build/deploy
CI:
if: contains(github.event.pull_request.labels.*.name, 'safe')
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
with:
# repo settings에서 설정한 secrets 값을 사용한다.
ref: ${{ github.event.pull_request.head.sha }}
token: ${{ secrets.ACCESS_TOKEN }}
submodules: true
### runner application java 설정
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
### gradlew 실행 권한 부여
- name: Grant execute permisstion for gradlew
run: chmod +x gradlew
### project test
- name: Test
if: contains(github.event.pull_request.labels.*.name, 'safe')
run: ./gradlew clean test -Pprofile=test
### project build
- name: Build with Gradle
if: github.event.pull_request.merged == true
run: ./gradlew clean build
### Docker Image Build and Push
- name: Login to Docker Hub
if: github.event.pull_request.merged == true
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set up Docker Buildx
if: github.event.pull_request.merged == true
uses: docker/setup-buildx-action@v2
- name: Build and push
if: github.event.pull_request.merged == true
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
# closed에 대한 server deploy
CD:
if: github.event.pull_request.merged == true
needs: [CI]
runs-on: ubuntu-20.04
steps:
### SSH Connect and Docker Image Pull and Container Run
- name: Docker Image Pull and Container Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEV_SSH_HOST }}
username: ${{ secrets.DEV_SSH_USERNAME }}
password: ${{ secrets.DEV_SSH_PASSWORD }}
key: ${{ secrets.DEV_SSH_KEY }}
port: ${{ secrets.DEV_SSH_PORT }}
script: |
docker stop emodiary-was
docker rm emodiary-was
docker image rm ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}
docker run -d -v /root/emodiary/resources:/app/resources --net emodiary-bridge --ip 172.30.0.3 -p 8090:8080 --name emodiary-was ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_REPONAME }}