Skip to content

Commit 1ddab17

Browse files
committed
Restore lost changes from #41
* Combine layers in Docker image * Use -c with jq when formatting client_payloads * Refactor waiting into a common function Originally authored by @duhow (David Girón <[email protected]>)
1 parent 3b8ca9d commit 1ddab17

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
FROM alpine:3.15.0
22

3-
RUN apk update
4-
RUN apk --no-cache add curl jq coreutils
3+
RUN apk update \
4+
&& apk --no-cache add curl jq coreutils
55

66
COPY entrypoint.sh /entrypoint.sh
77

entrypoint.sh

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,10 @@ validate_args() {
7575
exit 1
7676
fi
7777

78-
client_payload=$(echo '{}' | jq)
78+
client_payload=$(echo '{}' | jq -c)
7979
if [ "${INPUT_CLIENT_PAYLOAD}" ]
8080
then
81-
client_payload=$(echo "${INPUT_CLIENT_PAYLOAD}" | jq)
81+
client_payload=$(echo "${INPUT_CLIENT_PAYLOAD}" | jq -c)
8282
fi
8383

8484
ref="main"
@@ -106,6 +106,12 @@ api() {
106106
fi
107107
}
108108

109+
lets_wait() {
110+
local interval=${1:-$wait_interval}
111+
echo >&2 "Sleeping for $interval seconds"
112+
sleep "$interval"
113+
}
114+
109115
# Return the ids of the most recent workflow runs, optionally filtered by user
110116
get_workflow_runs() {
111117
since=${1:?}
@@ -135,8 +141,7 @@ trigger_workflow() {
135141
NEW_RUNS=$OLD_RUNS
136142
while [ "$NEW_RUNS" = "$OLD_RUNS" ]
137143
do
138-
echo >&2 "Sleeping for ${wait_interval} seconds"
139-
sleep "$wait_interval"
144+
lets_wait
140145
NEW_RUNS=$(get_workflow_runs "$SINCE")
141146
done
142147

@@ -160,8 +165,7 @@ wait_for_workflow_to_finish() {
160165

161166
while [[ "${conclusion}" == "null" && "${status}" != "completed" ]]
162167
do
163-
echo "Sleeping for \"${wait_interval}\" seconds"
164-
sleep "${wait_interval}"
168+
lets_wait
165169

166170
workflow=$(api "runs/$last_workflow_id")
167171
conclusion=$(echo "${workflow}" | jq -r '.conclusion')

0 commit comments

Comments
 (0)