Skip to content

Commit

Permalink
Use Slack workflows (#201)
Browse files Browse the repository at this point in the history
* Use Slack workflows

* Use SLACK_WEBHOOK_URL
  • Loading branch information
edigaryev authored Jan 14, 2025
1 parent cec270a commit c18ef9c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions .cirrus.star
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,18 @@ def on_build_failed(ctx):
if "Cron" not in ctx.payload.data.build.changeMessageTitle:
return

resp = http.post("https://slack.com/api/chat.postMessage", headers={
resp = http.post(env.get("SLACK_WEBHOOK_URL"), headers={
"Content-Type": "application/json",
"Authorization": "Bearer " + env.get("SLACK_TOKEN"),
}, json_body={
"channel": "#image-updates",
"text": "Build <https://cirrus-ci.com/build/{build_id}|{build_id} (\"{change_message_title}\")> failed on branch \"{branch_name}\" in repository \"{repository_name}\".".format(
build_id=ctx.payload.data.build.id, change_message_title=ctx.payload.data.build.changeMessageTitle,
branch_name=ctx.payload.data.build.branch, repository_name=ctx.payload.data.repository.name),
"text": "Build {build_id} (\"{change_message_title}\") failed on branch \"{branch_name}\" in repository \"{repository_name}\".".format(
build_id=ctx.payload.data.build.id,
change_message_title=ctx.payload.data.build.changeMessageTitle,
branch_name=ctx.payload.data.build.branch,
repository_name=ctx.payload.data.repository.name,
),
"url": "https://cirrus-ci.com/build/{build_id}".format(
build_id=ctx.payload.data.build.id,
),
})

if resp.status_code != 200:
Expand Down

0 comments on commit c18ef9c

Please sign in to comment.