-
-
Notifications
You must be signed in to change notification settings - Fork 64
57 lines (56 loc) · 1.78 KB
/
healthcheck.workflow.tmpl.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
on: # yamllint disable-line rule:truthy
workflow_call:
inputs:
sus:
description: 'a StartUp Script to run beforehand'
required: false
type: 'string'
service_name:
description: 'A service name to check health check uppon'
required: true
type: 'string'
timeout-minutes:
description: 'a timeout to waitfor running containers'
required: false
default: 2
type: 'number'
jobs:
health-check:
runs-on: 'ubuntu-latest'
steps:
- uses: 'actions/checkout@v4'
- uses: 'KengoTODA/actions-setup-docker-compose@v1'
with:
version: '2.20.2'
- name: 'Caching'
uses: 'actions/cache@v4'
with:
path: '/var/lib/docker/'
key: '${{ runner.os }}-health-${{ github.job }}'
- name: 'Setting up job'
if: '${{ inputs.sus }}'
run: |
${{ inputs.sus }}
- name: 'Starting the docker-compose stack'
run: |
echo -e "USERS=runner\nUSERNAME=octocat" > .env
docker-compose up -d ${{inputs.service_name}}
- name: 'Waiting for running containers'
timeout-minutes: '${{ inputs.timeout-minutes }}'
run: |
while :; do
echo "sleeping for 5s"
sleep 5s;
docker-compose ps ${{inputs.service_name}} | grep "starting" || exit 0
done
- name: 'Checking containers health'
run: |
docker-compose ps ${{inputs.service_name}} | grep "healthy"
- name: 'Checking for unattended volumes'
run: |
git diff --exit-code .
- name: 'Exporting logs'
if: '${{ failure() }}'
run: |
docker-compose ps ${{inputs.service_name}}
docker-compose logs ${{inputs.service_name}}