-
Notifications
You must be signed in to change notification settings - Fork 2
63 lines (53 loc) · 1.95 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
name: Java CD with Gradle
on:
push:
branches: [ "develop", "main", "Server/CD" ]
paths: ["Server/banchango/**"]
pull_request:
branches: [ "develop", "main", "Server/CD" ]
paths: ["Server/banchango/**"]
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Setup Gradle
uses: gradle/actions/setup-gradle@af1da67850ed9a4cedd57bfd976089dd991e2582 # v4.0.0
- name: make application-prod.yml
run: |
cd ./Server/banchango/src/main/resources
touch ./application-prod.properties
echo "${{ secrets.APPLICATION_PROD }}" > ./application-prod.properties
- name: Grant execute permission for gradlew
run: chmod +x ./Server/banchango/gradlew
- name: Build with Gradle
run: |
cd Server/banchango
./gradlew clean build -x test
- name: Docker build
run: |
cd Server/banchango
docker login -u ${{ secrets.SERVER_DOCKER_USERNAME }} -p ${{ secrets.SERVER_DOCKER_PASSWORD }}
docker build -t app .
docker tag app ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
docker push ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
- name: Deploy
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SERVER_HOST }} # EC2 인스턴스 퍼블릭 DNS
username: ec2-user
key: ${{ secrets.SERVER_PEM_KEY }} # pem 키
# 도커 작업
script: |
docker pull ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
docker stop $(docker ps -a -q)
docker run -d --log-driver=syslog -p 8080:8080 ${{ secrets.SERVER_DOCKER_USERNAME }}/banchango:latest
docker rm $(docker ps --filter 'status=exited' -a -q)
docker image prune -a -f