-
Notifications
You must be signed in to change notification settings - Fork 0
56 lines (47 loc) · 1.6 KB
/
gradle-cicd.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
name: Gradle CI & CD
on:
push:
branches:
- main
permissions:
contents: read
jobs:
Build-Deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Create properties
run: |
cd favor
echo "${{ secrets.GRADLE_PROPERTIES_CONTENT }}" > gradle.properties
mkdir -p src/main/resources
echo "${{ secrets.APPLICATION_YML_CONTENT }}" > src/main/resources/application.yml
- name: Grant execute permission for gradlew
run: |
cd favor
chmod +x gradlew
- name: Build with Gradle
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKERHUB_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
cd favor
./gradlew jib
- name: Deploy to Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.HOST_ADDRESS }}
username: ${{ secrets.SERVER_USERNAME }}
password: ${{ secrets.SERVER_PASSWORD }}
port : ${{ secrets.SERVER_PORT }}
script: |
docker stop ${{ secrets.APPLICATION_NAME }}
docker rm ${{ secrets.APPLICATION_NAME }}
docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
docker run -d -p ${{ secrets.DEPLOY_PORT }}:8080 -e TZ=Asia/Seoul --name ${{ secrets.APPLICATION_NAME }} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}