-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (58 loc) · 1.92 KB
/
build_and_deploy.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
name: TRIPY_DEPLOY
on:
push:
branches: ["main"]
jobs:
build:
runs-on: ubuntu-latest
steps:
# 체크아웃
- name: Checkout code
uses: actions/checkout@v3
# JDK 설치
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# 서브 모듈 접근
- name: Checkout repo
uses: actions/checkout@v3
with:
token: ${{ secrets.TRIPY_ACTION_TOKEN }}
submodules: true
# 서브 모듈 변경 점 있으면 update
- name: Git Submodule Update
run: |
git submodule update --remote --recursive
# gradlew 권한 변경
- name: Grant execute permission for gradlew
run : chmod +x gradlew
# 빌드(test는 제외)
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean build -x test
# Docker 이미지 빌드
- name: 도커 이미지 빌드
run: docker build -t gourderased/spring-project:latest .
# DockerHub 로그인
- name: Docker - Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
# Docker Hub 이미지 푸시
- name: Docker Hub 퍼블리시
run: docker push gourderased/spring-project:latest
- name: Depoly in AWS ec2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ubuntu
key: ${{ secrets.SSH_KEY }}
script: |
sudo docker stop $(sudo docker ps -a -q)
sudo docker rm $(sudo docker ps -a -q)
sudo docker pull gourderased/spring-project:latest
sudo docker run -d -p 8080:8080 -e TZ=Asia/Seoul --name tripy-server gourderased/spring-project:latest