-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.48 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
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
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 --network=host -d -p ${{ secrets.DEPLOY_PORT }}:8080 -e TZ=Asia/Seoul --name ${{ secrets.APPLICATION_NAME }} ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}