From 8d853f97de959f9323ce77a517a2dfa0bbfa01c0 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Tue, 1 Sep 2026 13:43:39 -0300 Subject: [PATCH 1/2] ci(frontend-deploy): name what is being deployed The cards identified a deploy by short sha, which says nothing about what is in it. Adds the pull request title under the headline, linked to the pull request. No API call is needed. A squash merge puts the title and number in the first line of the commit message, as "title (#123)", and all of the last forty commits on main match that. A direct push or a merge commit will not, so the number is optional and the title falls back to the whole line unlinked. The title goes full width as a context line rather than into the field grid, which is two narrow columns and would wrap a real title badly. Co-Authored-By: Claude Opus 5 (1M context) --- .../actions/notify-slack-deploy/action.yml | 25 +++++++++++++++++++ .../actions/notify-slack-deploy/payload.jq | 16 ++++++++++-- .../workflows/frontend-deploy-production.yml | 4 +++ 3 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.github/actions/notify-slack-deploy/action.yml b/.github/actions/notify-slack-deploy/action.yml index 0074de2e4ff4..e3507cba5435 100644 --- a/.github/actions/notify-slack-deploy/action.yml +++ b/.github/actions/notify-slack-deploy/action.yml @@ -30,6 +30,14 @@ inputs: run_url: description: Link to the deploy run, not to the run posting this. required: true + repo_url: + description: Repository URL, used to link the pull request. Omit to leave the title unlinked. + required: false + commit_message: + description: > + The deployed commit's message. Only its first line is used, which on a + squash merge is the pull request title. Omitted from the card if absent. + required: false started_at: description: When the deploy run started, ISO 8601. Omitted from the message if absent. required: false @@ -52,11 +60,26 @@ runs: COMMIT_SHA: ${{ inputs.commit_sha }} ACTOR: ${{ inputs.actor }} RUN_URL: ${{ inputs.run_url }} + REPO_URL: ${{ inputs.repo_url }} + COMMIT_MESSAGE: ${{ inputs.commit_message }} STARTED_AT: ${{ inputs.started_at }} ENDED_AT: ${{ inputs.ended_at }} run: | set -euo pipefail + # A squash merge puts the pull request title and number in the first + # line, as "title (#123)". A direct push or a merge commit will not + # match, so the number is optional and the title falls back to the + # whole line. + subject="$(printf '%s' "${COMMIT_MESSAGE:-}" | head -1)" + pr_number="$(printf '%s' "$subject" | sed -n 's/.*(#\([0-9]\{1,\}\))$/\1/p')" + title="$subject" + pr_url='' + if [ -n "$pr_number" ]; then + title="$(printf '%s' "$subject" | sed 's/ *(#[0-9]\{1,\})$//')" + [ -n "${REPO_URL:-}" ] && pr_url="$REPO_URL/pull/$pr_number" + fi + # Best effort: a timestamp that will not parse costs the message two # fields rather than failing the run. epoch() { date -u -d "$1" +%s 2>/dev/null || true; } @@ -83,6 +106,8 @@ runs: --arg actor "$ACTOR" \ --arg app_url "$APP_URL" \ --arg run_url "$RUN_URL" \ + --arg title "$title" \ + --arg pr_url "$pr_url" \ --arg started_epoch "$started_epoch" \ --arg started_label "$started_label" \ --arg duration "$duration" \ diff --git a/.github/actions/notify-slack-deploy/payload.jq b/.github/actions/notify-slack-deploy/payload.jq index 4cb7ae91fb34..3f3f3fd544ed 100644 --- a/.github/actions/notify-slack-deploy/payload.jq +++ b/.github/actions/notify-slack-deploy/payload.jq @@ -43,11 +43,22 @@ end) as $copy | # comes from the icon set on the Slack app itself. username: "\($service) Deploy", text: $copy.headline, - blocks: [ + blocks: ( + [ { type: "header", text: { type: "plain_text", text: $copy.headline } - }, + } + ] + # What shipped, full width rather than in the field grid below, which is two + # narrow columns and would wrap a real title badly. + + (if $title == "" then [] + elif $pr_url == "" then + [{ type: "context", elements: [{ type: "mrkdwn", text: $title }] }] + else + [{ type: "context", elements: [{ type: "mrkdwn", text: "<\($pr_url)|\($title)>" }] }] + end) + + [ { type: "section", text: { type: "mrkdwn", text: $copy.body } @@ -87,4 +98,5 @@ end) as $copy | ) } ] + ) } diff --git a/.github/workflows/frontend-deploy-production.yml b/.github/workflows/frontend-deploy-production.yml index b40ddb235f63..0262723b8329 100644 --- a/.github/workflows/frontend-deploy-production.yml +++ b/.github/workflows/frontend-deploy-production.yml @@ -37,6 +37,8 @@ jobs: commit_sha: ${{ github.sha }} actor: ${{ github.actor }} run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + repo_url: ${{ github.server_url }}/${{ github.repository }} + commit_message: ${{ github.event.head_commit.message }} run-unit-tests: runs-on: ubuntu-latest @@ -169,6 +171,8 @@ jobs: commit_sha: ${{ github.sha }} actor: ${{ github.actor }} run_url: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} + repo_url: ${{ github.server_url }}/${{ github.repository }} + commit_message: ${{ github.event.head_commit.message }} started_at: ${{ steps.outcome.outputs.started_at }} ended_at: ${{ steps.outcome.outputs.ended_at }} From 93941815758c6c57c423d6306d2f3d0484e32d18 Mon Sep 17 00:00:00 2001 From: Talisson Costa Date: Fri, 11 Sep 2026 13:37:54 -0300 Subject: [PATCH 2/2] fix(frontend-deploy): escape the title before it reaches Slack The title comes from the deployed commit subject, so it is the only free-form string in the card. A pull request titled " ship it" would have pinged the whole channel on merge, and "" would have rendered as a disguised link. Escapes the three characters Slack parses, ampersand first so the entities the other two produce are not re-encoded. Co-Authored-By: Claude Opus 5 (1M context) --- .github/actions/notify-slack-deploy/payload.jq | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/actions/notify-slack-deploy/payload.jq b/.github/actions/notify-slack-deploy/payload.jq index 3f3f3fd544ed..94c4e35594a1 100644 --- a/.github/actions/notify-slack-deploy/payload.jq +++ b/.github/actions/notify-slack-deploy/payload.jq @@ -1,6 +1,12 @@ # Slack Block Kit payload for a deploy notification. # Run with jq -n and the --arg values listed in action.yml. +# Slack only needs these three escaped, ampersand first so the entities the +# other two produce are not re-encoded. Without it a commit subject reading +# "" would ping the channel, and "" would render as a +# disguised link. +def mrkdwn: gsub("&"; "&") | gsub("<"; "<") | gsub(">"; ">"); + ($environment | (.[0:1] | ascii_upcase) + .[1:]) as $env_name | # Only in_progress, success and cancelled need their own words. Everything @@ -54,9 +60,9 @@ end) as $copy | # narrow columns and would wrap a real title badly. + (if $title == "" then [] elif $pr_url == "" then - [{ type: "context", elements: [{ type: "mrkdwn", text: $title }] }] + [{ type: "context", elements: [{ type: "mrkdwn", text: ($title | mrkdwn) }] }] else - [{ type: "context", elements: [{ type: "mrkdwn", text: "<\($pr_url)|\($title)>" }] }] + [{ type: "context", elements: [{ type: "mrkdwn", text: "<\($pr_url)|\($title | mrkdwn)>" }] }] end) + [ {