From 24a47a419a9af231b6c991d5f60deb64580ca5c1 Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Mon, 3 Mar 2025 22:07:57 +0000 Subject: [PATCH] Build/Test Tools: Remove redundant escaping from the commit message that's passed to the Slack API. This escaping is no longer needed since all instances of inline expressions were removed from workflows in r59679. The commit message can now be treated as a plain text string in an environment variable throughout the workflow. Props johnbillion, swissspidy Unprops johnblackbourn See #62221 git-svn-id: https://develop.svn.wordpress.org/trunk@59920 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/slack-notifications.yml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index af5b75c8ef..3ba1c193a8 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -135,6 +135,7 @@ jobs: with: retries: 2 retry-exempt-status-codes: 418 + result-encoding: string script: | const commit_details = await github.rest.repos.getCommit({ owner: context.repo.owner, @@ -143,18 +144,10 @@ jobs: }); return commit_details.data.commit.message; - - name: Prepare commit message. - id: commit-message - run: | - # shellcheck disable=SC2016 - COMMIT_MESSAGE="$(echo "${COMMIT_MSG_RAW}" | awk 'NR==1' | sed 's/`/\\`/g' | sed 's/\"/\\\\\\"/g' | sed 's/\$/\\$/g')" - echo "commit_message_escaped=${COMMIT_MESSAGE}" >> "$GITHUB_OUTPUT" - env: - COMMIT_MSG_RAW: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && fromJson( steps.current-commit-message.outputs.result ) || github.event.head_commit.message }} - - name: Construct payload and store as an output id: create-payload run: | + COMMIT_MSG="$(echo "${COMMIT_MSG_RAW}" | awk 'NR==1')" PAYLOAD="$( jq \ -n \ --arg workflow_name "${GITHUB_WORKFLOW}" \ @@ -165,7 +158,7 @@ jobs: )" echo "payload=$PAYLOAD" >> "$GITHUB_OUTPUT" env: - COMMIT_MSG: ${{ steps.commit-message.outputs.commit_message_escaped }} + COMMIT_MSG_RAW: ${{ ( github.event_name == 'workflow_dispatch' || github.event_name == 'schedule' ) && fromJson( steps.current-commit-message.outputs.result ) || github.event.head_commit.message }} # Posts notifications when a workflow fails. failure: