-
Notifications
You must be signed in to change notification settings - Fork 43
127 lines (109 loc) · 3.48 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Java CI with Gradle
on:
schedule:
- cron: '0 */6 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Get last successful run time
id: last_run
uses: actions/github-script@v7
with:
script: |
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'gradle.yml',
branch: context.ref.replace('refs/heads/', ''),
status: 'success',
per_page: 1
});
if (runs.data.workflow_runs.length > 0) {
const lastRunTime = runs.data.workflow_runs[0].updated_at;
core.setOutput('lastRunTime', lastRunTime);
} else {
core.setOutput('lastRunTime', '1970-01-01T00:00:00Z');
}
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check for new commits since last successful run
id: check_commits
run: |
git fetch origin
COMMITS=$(git rev-list --since="${{ steps.last_run.outputs.lastRunTime }}" HEAD)
if [ -z "$COMMITS" ]; then
echo "No new commits found."
echo "new_commits=false" >> $GITHUB_OUTPUT
else
echo "New commits found."
echo "new_commits=true" >> $GITHUB_OUTPUT
fi
- name: Exit if no new commits
if: steps.check_commits.outputs.new_commits == 'false'
run: exit 0
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
run: ./gradlew build
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: artifacts
path: ./build/libs/
- name: Release Build
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
body_path: CHANGELOG.md
files: "./build/libs/**"
- name: Build Success
uses: rjstone/discord-webhook-notify@v1
if: success()
with:
severity: info
details: Build Succeeded!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: Build Failure
uses: rjstone/discord-webhook-notify@v1
if: failure()
with:
severity: error
details: Build Failed!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
- name: Build Cancelled
uses: rjstone/discord-webhook-notify@v1
if: cancelled()
with:
severity: warn
details: Build Cancelled!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}
checkstyle:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 21
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Checkstyle with Gradle
run: ./gradlew checkstyleMain
- name: Checkstyle Failure
uses: rjstone/discord-webhook-notify@v1
if: failure()
with:
severity: error
color: '#ff5500'
details: Checkstyle Failed!
webhookUrl: ${{ secrets.DISCORD_WEBHOOK }}