From 40506e7e64965abf9dc7357f5c1c0b20f7f31f01 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Fri, 20 Aug 2021 18:58:18 +0000 Subject: [PATCH] Build/Test Tools: Include the commit short summary in Slack messages. This gives more context to GitHub Action related Slack messages without the need to click the workflow URL, or unfurl the links (which shows lots of unnecessary information, such as the repository description and image). Props earnjam. See #52644. git-svn-id: https://develop.svn.wordpress.org/trunk@51647 602fd350-edb4-49c9-b593-d223f7449a82 --- .github/workflows/slack-notifications.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/slack-notifications.yml b/.github/workflows/slack-notifications.yml index 8639425cd1..5d4981b901 100644 --- a/.github/workflows/slack-notifications.yml +++ b/.github/workflows/slack-notifications.yml @@ -60,9 +60,18 @@ jobs: id: previous-conclusion run: echo "::set-output name=previous_conclusion::${{ steps.previous-result.outputs.result }}" + - name: Prepare commit message. + id: commit-message + run: | + COMMIT_MESSAGE=$(cat <<'EOF' | awk 'NR==1' | sed 's/\"/\\"/g' + ${{ github.event.workflow_run.head_commit.message }} + EOF + ) + echo "::set-output name=commit_message_escaped::${COMMIT_MESSAGE}" + - name: Construct payload and store as an output id: create-payload - run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.event.workflow_run.name }}\",\"ref_name\":\"${{ github.event.workflow_run.head_branch }}\",\"run_url\":\"${{ github.event.workflow_run.html_url }}\"}" + run: echo "::set-output name=payload::{\"workflow_name\":\"${{ github.event.workflow_run.name }}\",\"ref_name\":\"${{ github.event.workflow_run.head_branch }}\",\"run_url\":\"${{ github.event.workflow_run.html_url }}\",\"commit_message\":\"${{ steps.commit-message.outputs.commit_message_escaped }}\"}" # Posts notifications when a workflow fails. failure: