-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
d802ead
commit b2f3640
Showing
2 changed files
with
43 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: "Wait for ES Data" | ||
description: "Waits for data on ES indices" | ||
inputs: | ||
index: | ||
description: "Which ES index to look at" | ||
required: true | ||
es_host: | ||
description: "the ES host URL" | ||
default: "http://localhost:9200" | ||
retries: | ||
description: "How many times to retry checking for data. (1s interval)" | ||
default: "100" | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Wait for data | ||
shell: bash | ||
run: | | ||
URL="${{inputs.es_host}}/${{ inputs.index }}/_search?size=0" | ||
HEADER="Content-Type: application/json" | ||
MAX_RETRIES=${{inputs.retries}} | ||
echo "Checking index: ${{ inputs.index }}" | ||
for ((i = 1; i <= MAX_RETRIES; i++)); do | ||
result=$(curl -s -X GET "$URL" -H "$HEADER" | jq '.hits.total.value') | ||
if [ "$result" -gt 0 ]; then | ||
echo "Data found: $result documents in index ${{ inputs.index }}" | ||
exit 0 | ||
fi | ||
echo "No data yet. Retrying in 1s... ($i/$MAX_RETRIES)" | ||
sleep 1 | ||
done | ||
echo "No data found after $MAX_RETRIES retries." | ||
exit 1 |