Skip to content

Commit

Permalink
Fixed GitHub notification not handling longer deployment IDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexSkrypnyk committed Jul 18, 2024
1 parent 0a54ee1 commit af9ffe4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .scaffold/tests/bats/notify.bats
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ load _helper.bash
declare -a STEPS=(
"Started dispatching notifications."
"Started GitHub notification for post_deployment event."
"@curl -X GET -H Authorization: token token12345 -H Accept: application/vnd.github.v3+json -s https://api.github.com/repos/myorg/myrepo/deployments?ref=mybranch # [{\"id\": \"${app_id}\", \"othervar\": \"54321\"},{\"id\": \"987654321\", \"othervar\": \"12345\"}]"
"@curl -X GET -H Authorization: token token12345 -H Accept: application/vnd.github.v3+json -s https://api.github.com/repos/myorg/myrepo/deployments?ref=mybranch # [{\"id\": \"${app_id}\", \"othervar\": \"54321\"},{\"id\": \"98765432101\", \"othervar\": \"12345\"}]"
"@curl -X POST -H Accept: application/vnd.github.v3+json -H Authorization: token token12345 https://api.github.com/repos/myorg/myrepo/deployments/123456789/statuses -s -d {\"state\":\"success\", \"environment_url\": \"https://develop.testproject.com\"} # {\"state\": \"success\", \"othervar\": \"54321\"}"
"Marked deployment as finished."
"Finished GitHub notification for post_deployment event."
Expand Down
4 changes: 2 additions & 2 deletions scripts/drevops/notify-github.sh
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if [ "${DREVOPS_NOTIFY_EVENT}" = "pre_deployment" ]; then
deployment_id="$(echo "${payload}" | extract_json_value "id")"

# Check deployment ID.
{ [ "${#deployment_id}" != "9" ] || [ "$(expr "x${deployment_id}" : "x[0-9]*$")" -eq 0 ]; } && fail "Unable to get a deployment ID." && exit 1
{ [ "${#deployment_id}" -lt 9 ] || [ "${#deployment_id}" -gt 11 ] || [ "$(expr "x${deployment_id}" : "x[0-9]*$")" -eq 0 ]; } && fail "Failed to get a deployment ID for a started operation. Payload: ${payload}" && exit 1

note "Marked deployment as started."
else
Expand All @@ -101,7 +101,7 @@ else
deployment_id="$(echo "${payload}" | extract_json_first_value "id")"

# Check deployment ID.
{ [ "${#deployment_id}" != "9" ] || [ "$(expr "x${deployment_id}" : "x[0-9]*$")" -eq 0 ]; } && fail "Unable to get a deployment ID." && exit 1
{ [ "${#deployment_id}" -lt 9 ] || [ "${#deployment_id}" -gt 11 ] || [ "$(expr "x${deployment_id}" : "x[0-9]*$")" -eq 0 ]; } && fail "Failed to get a deployment ID for a finished operation. Payload: ${payload}" && exit 1

# Post status update.
payload="$(curl \
Expand Down

1 comment on commit af9ffe4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.