Skip to content

Commit 243c096

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 3d1d8c0 commit 243c096

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
@@ -69,10 +69,10 @@ validate_args() {
6969
exit 1
7070
fi
7171

72-
client_payload=$(echo '{}' | jq)
72+
client_payload=$(echo '{}' | jq -c)
7373
if [ "${INPUT_CLIENT_PAYLOAD}" ]
7474
then
75-
client_payload=$(echo "${INPUT_CLIENT_PAYLOAD}" | jq)
75+
client_payload=$(echo "${INPUT_CLIENT_PAYLOAD}" | jq -c)
7676
fi
7777

7878
ref="main"
@@ -100,6 +100,12 @@ api() {
100100
fi
101101
}
102102

103+
lets_wait() {
104+
local interval=${1:-$wait_interval}
105+
echo >&2 "Sleeping for $interval seconds"
106+
sleep "$interval"
107+
}
108+
103109
# Return the ids of the most recent workflow runs, optionally filtered by user
104110
get_workflow_runs() {
105111
since=${1:?}
@@ -129,8 +135,7 @@ trigger_workflow() {
129135
NEW_RUNS=$OLD_RUNS
130136
while [ "$NEW_RUNS" = "$OLD_RUNS" ]
131137
do
132-
echo >&2 "Sleeping for ${wait_interval} seconds"
133-
sleep "$wait_interval"
138+
lets_wait
134139
NEW_RUNS=$(get_workflow_runs "$SINCE")
135140
done
136141

@@ -154,8 +159,7 @@ wait_for_workflow_to_finish() {
154159

155160
while [[ "${conclusion}" == "null" && "${status}" != "completed" ]]
156161
do
157-
echo "Sleeping for \"${wait_interval}\" seconds"
158-
sleep "${wait_interval}"
162+
lets_wait
159163

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

0 commit comments

Comments
 (0)