-
Notifications
You must be signed in to change notification settings - Fork 0
74 lines (56 loc) · 2.22 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
name: Java CI with Gradle
on:
push:
branches: [ "main" ] #push할 경우 사용 할 branch 명 기입
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Java Version 기입
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
#Secret에 설정해둔 YML파일 (BASE64로 인코딩 되어있어야 함) 설정
- name: Set YML
run: |
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML }}" > src/main/resources/application.yml
find src
#gradlew 권한 설정
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
# Spring Boot Build
- name: Spring Boot Build
run: ./gradlew clean build -x test
#————————— Docker ——————————
# Docker Image Build
- name: Docker Image Build
run: docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGENAME }} .
# DockerHub Login
- name: Docker Hub Login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# Docker Hub push
- name: docker Hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGENAME }}
#————————— EC2 ——————————
# AWS EC2 Server Connect & Docker 명령어 실행
- name: AWS EC2 Connection
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
password: ${{ secrets.EC2_PASSWORD }}
port: ${{ secrets.EC2_SSH_PORT }}
timeout: 60s
script: |
sudo docker stop ${{ secrets.DOCKERHUB_IMAGENAME }}
sudo docker rm ${{ secrets.DOCKERHUB_IMAGENAME }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGENAME }}
sudo docker run -it -d -p 8080:8080 --name ${{ secrets.DOCKERHUB_IMAGENAME }} -e TZ=Asia/Seoul ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGENAME }}