-
Notifications
You must be signed in to change notification settings - Fork 0
62 lines (51 loc) · 1.65 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
name: Java CI/CD with Gradle
on:
push:
branches: [ "main" ]
permissions:
contents: read
jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# 1. Java 17 세팅
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# 2. Spring Boot 애플리케이션 빌드
- name: Build with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: clean bootJar
# 3. Docker 이미지 빌드
- name: docker image build
run: docker buildx build --platform=linux/arm64 -t ${{ secrets.DOCKERHUB_USERNAME }}/schoolzone:latest .
# 4. Dockerhub 로그인
- name: docker login
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# 5. Dockerhub push
- name: docker hub push
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/schoolzone:latest
# 6. 안쓰는 이미지 & 컨테이너 삭제
- name: docker image & container prune
run: |
docker container prune
docker image prune -a
- name: Connect to WAS & Execute Application
uses: appleboy/[email protected]
with:
host: ${{ secrets.WAS_HOST }}
username: ${{ secrets.WAS_USERNAME }}
password: ${{ secrets.SSH_PASSWORD }}
port: ${{ secrets.WAS_SSH_PORT }}
script: |
cd ~/schoolzone
docker-compose down
docker-compose pull
docker-compose up -d