From b55ca123e9b7e152e0ceece9dca9093d776f268e Mon Sep 17 00:00:00 2001 From: Liz Kenyon Date: Tue, 22 Sep 2026 11:07:04 -0500 Subject: [PATCH 1/2] Simplify Gardener Slack notifications --- .github/workflows/gardener-notify-slack.yml | 51 ++------------------- 1 file changed, 5 insertions(+), 46 deletions(-) diff --git a/.github/workflows/gardener-notify-slack.yml b/.github/workflows/gardener-notify-slack.yml index 8bcb5a8bb..71c3b993a 100644 --- a/.github/workflows/gardener-notify-slack.yml +++ b/.github/workflows/gardener-notify-slack.yml @@ -1,6 +1,6 @@ name: Gardener - Notify Slack # Runs after `Gardener - Notify Event` completes and does the real work: -# applies the devtools-gardener label and posts a summary to Slack. +# applies the devtools-gardener label and posts a linked title to Slack. # # The workflow_run trigger runs this job in the default-branch context with # full GITHUB_TOKEN permissions and Actions secret access — this is what @@ -59,57 +59,16 @@ jobs: SLACK_BOT_TOKEN: ${{ secrets.SLACK_GARDENER_BOT_TOKEN }} SLACK_CHANNEL_ID: ${{ vars.GARDENER_SLACK_CHANNEL_ID }} run: | - KIND=$(jq -r 'if has("pull_request") then "PR" else "Issue" end' event.json) - # Pull the body out, truncate, then convert GitHub Markdown to - # Slack mrkdwn. Links and fenced code blocks are stashed before - # the HTML-escape pass so their contents survive verbatim (a `&` - # inside a URL must stay raw, and code content shouldn't be - # mangled). Blockquote `> ` markers are also stashed so the - # `>` → `>` escape doesn't break them. Everything else is - # HTML-escaped so user-supplied `<`, `>`, `&` can't collide - # with Slack link syntax or injected mentions like . - BODY=$(jq -r '(.issue // .pull_request).body // ""' event.json) - if [ ${#BODY} -gt 1000 ]; then - BODY="${BODY:0:1000}…" - fi - BODY=$(printf '%s' "$BODY" | perl -0777 -pe ' - my @u; - s{\[([^\]]+)\]\(([^)]+)\)}{push @u, $2; "\x01$#u\x02$1\x03"}ge; - my @c; - s{^```[^\n]*\n(.*?)\n```$}{push @c, $1; "\x04$#c\x05"}gems; - s/^> /\x06/gm; - s/^#{1,6}\s+(.+)$/*$1*/gm; - s/\*\*(.+?)\*\*/*$1*/g; - s/^(\s*)- \[x\]\s+/$1✓ /gm; - s/^(\s*)[-*]\s+/$1• /gm; - s/&/&/g; - s//>/g; - s/\x06/> /g; - s{\x01(\d+)\x02(.*?)\x03}{"<$u[$1]|$2>"}ge; - s{\x04(\d+)\x05}{"```\n$c[$1]\n```"}ge; - ') jq \ --arg channel "$SLACK_CHANNEL_ID" \ - --arg kind "$KIND" \ - --arg body "$BODY" \ ' def escape: gsub("&";"&") | gsub("<";"<") | gsub(">";">"); (.issue // .pull_request) as $i - | ([$i.labels[]?.name | select(. != "devtools-gardener")] - | map("`\(.)`") | join(" ")) as $labels - | (if $kind == "PR" - then " · \($i.changed_files) files, +\($i.additions)/-\($i.deletions)" - + (if $i.draft then " · draft" else "" end) - else "" end) as $meta - | [ "*<\($i.html_url)|\($kind) #\($i.number)>* — \(($i.title | escape))", - "_opened by \($i.user.login)\($meta)_" ] - + (if $body != "" then [$body] else [] end) - + (if $labels != "" then [$labels] else [] end) - | join("\n") as $msg - | { channel: $channel, text: "\($kind) #\($i.number): \($i.title)", - blocks: [{ type: "section", text: { type: "mrkdwn", text: $msg } }] } + | { channel: $channel, + text: "<\($i.html_url)|\($i.title | escape)>", + unfurl_links: false, + unfurl_media: false } ' event.json | curl -sf -X POST \ -H "Authorization: Bearer $SLACK_BOT_TOKEN" \ -H 'Content-type: application/json; charset=utf-8' \ From d18aecdec1c1ea91270ebbc85fc28bfed8e53764 Mon Sep 17 00:00:00 2001 From: Liz Kenyon Date: Tue, 22 Sep 2026 13:58:27 -0500 Subject: [PATCH 2/2] Prefix Gardener notifications with repo name --- .github/workflows/gardener-notify-slack.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/gardener-notify-slack.yml b/.github/workflows/gardener-notify-slack.yml index 71c3b993a..d4241fa6c 100644 --- a/.github/workflows/gardener-notify-slack.yml +++ b/.github/workflows/gardener-notify-slack.yml @@ -1,6 +1,6 @@ name: Gardener - Notify Slack # Runs after `Gardener - Notify Event` completes and does the real work: -# applies the devtools-gardener label and posts a linked title to Slack. +# applies the devtools-gardener label and posts a repo-prefixed linked title to Slack. # # The workflow_run trigger runs this job in the default-branch context with # full GITHUB_TOKEN permissions and Actions secret access — this is what @@ -66,7 +66,7 @@ jobs: (.issue // .pull_request) as $i | { channel: $channel, - text: "<\($i.html_url)|\($i.title | escape)>", + text: "\(.repository.name) · <\($i.html_url)|\($i.title | escape)>", unfurl_links: false, unfurl_media: false } ' event.json | curl -sf -X POST \