-
Notifications
You must be signed in to change notification settings - Fork 36
53 lines (46 loc) · 1.31 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
name: Java CI with Gradle
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle wrapper
run: ./gradlew build --no-daemon
- name: Run app and test health
run: |
BOOT_WAIT_SECONDS=10
LOG_FILE=app.log
# start app in background
java -jar build/libs/springboots2idemo-*.jar > $LOG_FILE 2>&1 &
# wait for server start and test health
sleep $BOOT_WAIT_SECONDS
HEALTH=$(curl http://localhost:9000/health)
# stop app
PID=$(ps -ef | grep "springboots2idemo-" | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
echo App is already stopped or did not start
exit 1
else
echo "stop app (kill $PID)"
kill $PID
fi
# print app logs
echo "-- logs --"
cat $LOG_FILE
rm -f $LOG_FILE
# test app health
echo "-- test --"
if [ "$HEALTH" = '{"status":"UP"}' ]; then
echo "App started healthy"
else
echo "App not healthy"
exit 1
fi