-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (70 loc) · 2.58 KB
/
gradle.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
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will build a Java project with Gradle and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-gradle
name: KHUMON CI TEST with Gradle
on:
#이벤트 감지
pull_request:
types: [closed]
#특정 브렌치에 대하여 설정
push:
branches : ["feat/34-test-deploy", "feat/36-nginx", "feat/51-deploy-ec2"]
workflow_dispatch:
permissions: write-all
jobs:
build:
runs-on: ubuntu-latest
steps: # STEP BY STEP 실행
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17' #JDK 17.
distribution: 'zulu'
- name: make application-prod.yml
run: |
cd ./src/main
cd ./resources
# application.yml 파일 생성하기
touch ./application-prod.yml
echo "${{ secrets.APPLICATION_PROD }}" >> ./application-prod.yml
shell: bash
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew clean build
#jar 실행파일생성
- name: Build the *.jar executable as Gradle
uses: actions/upload-artifact@v2
with:
name: jarfile
path: build/libs/KHUMON-0.0.1-SNAPSHOT.jar
#파일 여부확인
- name: checkout file list
run: ls
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD}}
- name: Build and Push Docker Image of khumon
run: |
docker buildx create --use
docker buildx build -t chy0310/khumon:latest . --push
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
password: ${{ secrets.EC2_SECRET }}
script: |
sh ~/deploy.sh
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker rmi $(sudo docker images -q)
sudo docker-compose up --build -d