Skip to content

Commit

Permalink
Setting up isanteplus wait action
Browse files Browse the repository at this point in the history
  • Loading branch information
pmanko committed Jan 21, 2022
0 parents commit a9fdbeb
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM alpine:latest

COPY entrypoint.sh /entrypoint.sh

ENTRYPOINT [ "/entrypoint.sh" ]
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Wait-for-isanteplus Github Action

This action prints "Hello World" or "Hello" + the name of a person to greet to the log.

## Inputs

## `target-url`

**Required**

## `interval`

**Required**
## `timeout`

**Required**
## Example usage

uses: actions/action-wait-for-isanteplus@v1
with:
target-url: http://localhost:8080/openmrs
timeout: 1000
interval: 10
23 changes: 23 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# action.yml
name: 'Wait For iSantePlus'
description: 'Wait for iSantePlus to be fully up'
inputs:
target-url:
description: 'Where iSantePlus is running'
required: true
default: 'http://localhost:8080/openmrs'
interval:
description: 'How often to check status in ms'
required: true
default: '1000'
timeout:
description: 'How long to try for in ms'
required: true
default: '1000000'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.target-url }}
- ${{ inputs.interval }}
- ${{ inputs.timeout }}
35 changes: 35 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash


url=$1
interval=$2
timeout=$3

TIMEOUT_END=$(($(date +%s) + $timeout))


while :; do
echo "Waiting for $1"

response=$(curl -u admin:Admin123 -s -w "\n%{http_code}" $url/ws/fhir2/R4/metadata?_format=json)
response=(${response[@]}) # convert to array
code=${response[-1]} # get last element (last line)

echo $code

body=${response[@]::${#response[@]}-1} # get all elements except last

if [[ "${body[0]}" == *"CapabilityStatement"* ]]; then
echo "Got Metadata!"
exit 0
else
echo "Still waiting..."
fi

if [ $(date +%s) -ge $TIMEOUT_END ]; then
echo "Operation timed out!"
exit 1
fi

sleep $interval
done

0 comments on commit a9fdbeb

Please sign in to comment.