Skip to content

Commit 5aa9d92

Browse files
authored
Merge pull request #6 from cloudbeds/update-v1.6.5
update to v1.6.5
2 parents ca5ade1 + 1653161 commit 5aa9d92

File tree

3 files changed

+37
-4
lines changed

3 files changed

+37
-4
lines changed

Dockerfile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
FROM public.ecr.aws/docker/library/alpine:3.15.0
22

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

56
COPY entrypoint.sh /entrypoint.sh
67

action.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ inputs:
1212
description: "The repository where the workflow is contained."
1313
required: true
1414
github_token:
15-
description: "The Github access token with access to the repository. Its recommended you put it under secrets."
15+
description: "The Github access token with access to the repository. It is recommended you put this token under secrets."
1616
required: true
1717
github_user:
1818
description: "The name of the github user whose access token is being used to trigger the workflow."
@@ -38,11 +38,21 @@ inputs:
3838
wait_workflow:
3939
description: 'Wait for workflow to finish. default: true'
4040
required: false
41+
comment_downstream_url:
42+
description: 'Comment API link for commenting the downstream job URL'
43+
required: false
44+
default: ''
45+
comment_github_token:
46+
description: "The Github access token with access to the repository for comment URL. It is recommended you put this token under secrets."
47+
required: false
48+
default: ${{ github.token }}
4149
outputs:
4250
workflow_id:
4351
description: The ID of the workflow that was triggered by this action
4452
workflow_url:
4553
description: The URL of the workflow that was triggered by this action
54+
conclusion:
55+
description: Conclusion of the job, i.e pass/failure
4656
runs:
4757
using: 'docker'
4858
image: 'Dockerfile'

entrypoint.sh

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ validate_args() {
8484

8585
lets_wait() {
8686
echo "Sleeping for ${wait_interval} seconds"
87-
sleep $wait_interval
87+
sleep "$wait_interval"
8888
}
8989

9090
api() {
@@ -101,7 +101,11 @@ api() {
101101
echo >&2 "api failed:"
102102
echo >&2 "path: $path"
103103
echo >&2 "response: $response"
104-
exit 1
104+
if [[ "$response" == *'"Server Error"'* ]]; then
105+
echo "Server error - trying again"
106+
else
107+
exit 1
108+
fi
105109
fi
106110
}
107111

@@ -148,6 +152,19 @@ trigger_workflow() {
148152
join -v2 <(echo "$OLD_RUNS") <(echo "$NEW_RUNS")
149153
}
150154

155+
comment_downstream_link() {
156+
if response=$(curl --fail-with-body -sSL -X POST \
157+
"${INPUT_COMMENT_DOWNSTREAM_URL}" \
158+
-H "Authorization: Bearer ${INPUT_COMMENT_GITHUB_TOKEN}" \
159+
-H 'Accept: application/vnd.github.v3+json' \
160+
-d "{\"body\": \"Running downstream job at $1\"}")
161+
then
162+
echo "$response"
163+
else
164+
echo >&2 "failed to comment to ${INPUT_COMMENT_DOWNSTREAM_URL}:"
165+
fi
166+
}
167+
151168
wait_for_workflow_to_finish() {
152169
last_workflow_id=${1:?}
153170
last_workflow_url="${GITHUB_SERVER_URL}/${INPUT_OWNER}/${INPUT_REPO}/actions/runs/${last_workflow_id}"
@@ -159,6 +176,10 @@ wait_for_workflow_to_finish() {
159176
echo "workflow_url=${last_workflow_url}" >> $GITHUB_OUTPUT
160177
echo ""
161178

179+
if [ -n "${INPUT_COMMENT_DOWNSTREAM_URL}" ]; then
180+
comment_downstream_link ${last_workflow_url}
181+
fi
182+
162183
conclusion=null
163184
status=
164185

@@ -172,6 +193,7 @@ wait_for_workflow_to_finish() {
172193

173194
echo "Checking conclusion [${conclusion}]"
174195
echo "Checking status [${status}]"
196+
echo "conclusion=${conclusion}" >> $GITHUB_OUTPUT
175197
done
176198

177199
if [[ "${conclusion}" == "success" && "${status}" == "completed" ]]

0 commit comments

Comments
 (0)