Skip to content

Commit c933d1d

Browse files
author
Tamas Pallos
committed
Add healthcheck github action
1 parent 6091c6a commit c933d1d

2 files changed

Lines changed: 53 additions & 0 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Tools which are commonly used by other JORE4 projects
88

99
- [Tools for Docker](#tools-for-docker)
1010
- [read-secrets.sh](#read-secretssh)
11+
- [Github Actions](#github-actions)
12+
- [Healthcheck](#healthcheck)
1113

1214
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1315

@@ -54,3 +56,25 @@ RUN curl -o /tmp/read-secrets.sh "https://raw.githubusercontent.com/HSLdevcom/jo
5456
# read docker secrets into environment variables and run application
5557
CMD /bin/bash -c "source /tmp/read-secrets.sh && java -jar /.../xxx.jar"
5658
```
59+
60+
## Github Actions
61+
62+
### Healthcheck
63+
64+
Runs a user-defined script to check whether a service is up and running
65+
66+
Parameters:
67+
68+
- retries: How many times to retry the healthcheck script before it fails
69+
(default: 20)
70+
- wait_between: How many seconds to wait in between retries (default: 5)
71+
- command: User-defined command for checking health of a service (required)
72+
73+
Example usage:
74+
75+
```
76+
steps:
77+
- uses: HSLdevcom/jore4-tools/github-actions/healthcheck@healthcheck-v1
78+
with:
79+
command: "curl --fail http://localhost:3200/actuator/health --output /dev/null --silent"
80+
```
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: "Run healthcheck"
2+
description:
3+
"Runs a user-defined command line script to see whether a service is up and
4+
running"
5+
inputs:
6+
retries:
7+
description: How many times to retry the healthcheck script before it fails
8+
required: false
9+
default: 20
10+
wait_between:
11+
description: How many seconds to wait in between retries
12+
required: false
13+
default: 5
14+
command:
15+
description: User-defined command for checking health
16+
required: true
17+
18+
runs:
19+
using: "composite"
20+
steps:
21+
- name: Verify that service is up and running
22+
run: |
23+
for i in {1..${{ inputs.retries }}}; do
24+
${{ inputs.command }} && exit 0
25+
sleep ${{ inputs.wait_between }}
26+
echo $i
27+
done
28+
exit 1
29+
shell: bash

0 commit comments

Comments
 (0)