From 2788b1247f2faa3d5ddd0c7abd9213799d57a80f Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 10:37:06 -0400 Subject: [PATCH 01/17] Add github workflow to trigger webhook to post to Teams --- .github/workflows/notify-teams.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .github/workflows/notify-teams.yml diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml new file mode 100644 index 00000000..7ce50969 --- /dev/null +++ b/.github/workflows/notify-teams.yml @@ -0,0 +1,20 @@ +name: Notify Teams on PR Creation + +on: + pull_request: + types: [opened] + +jobs: + notify: + runs-on: ubuntu-latest + + steps: + - name: Send notification to Teams channel + env: + TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + curl -H 'Content-Type: application/json' -d '{ + "text": "A new Pull Request has been created: **'"$PR_TITLE"'**. [View PR]('"$PR_URL"')" + }' $TEAMS_WEBHOOK_URL From 4c89d70dbcdd7ae3c5916fba9eb47da5e7a231cc Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 12:33:33 -0400 Subject: [PATCH 02/17] Rework workflow to include an attachment --- .github/workflows/notify-teams.yml | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 7ce50969..ae7e08b2 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -16,5 +16,27 @@ jobs: PR_URL: ${{ github.event.pull_request.html_url }} run: | curl -H 'Content-Type: application/json' -d '{ - "text": "A new Pull Request has been created: **'"$PR_TITLE"'**. [View PR]('"$PR_URL"')" + "attachments": [ + { + "contentType": "application/vnd.microsoft.card.adaptive", + "content": { + "type": "AdaptiveCard", + "version": "1.0", + "body": [ + { + "type": "TextBlock", + "text": "A new Pull Request has been created: **'"$PR_TITLE"'**", + "wrap": true + } + ], + "actions": [ + { + "type": "Action.OpenUrl", + "title": "View PR", + "url": "'"$PR_URL"'" + } + ] + } + } + ] }' $TEAMS_WEBHOOK_URL From c5c76fb03e2c367f2125a0778953a7eaf44d62d1 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 13:07:13 -0400 Subject: [PATCH 03/17] Add more formatting for the Teams card --- .github/workflows/notify-teams.yml | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index ae7e08b2..81424cd0 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -14,18 +14,35 @@ jobs: TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} PR_TITLE: ${{ github.event.pull_request.title }} PR_URL: ${{ github.event.pull_request.html_url }} + PR_BODY: ${{ github.event.pull_request.body }} run: | + # Send an Adaptive Card to Teams with attachments curl -H 'Content-Type: application/json' -d '{ + "type": "message", "attachments": [ { "contentType": "application/vnd.microsoft.card.adaptive", "content": { + "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "type": "AdaptiveCard", - "version": "1.0", + "version": "1.4", "body": [ { "type": "TextBlock", - "text": "A new Pull Request has been created: **'"$PR_TITLE"'**", + "size": "Large", + "weight": "Bolder", + "text": "New Pull Request Created", + "horizontalAlignment": "Center" + }, + { + "type": "TextBlock", + "text": "**Title:** $PR_TITLE", + "wrap": true, + "separator": true + }, + { + "type": "TextBlock", + "text": "**Description:** $PR_BODY", "wrap": true } ], @@ -33,10 +50,10 @@ jobs: { "type": "Action.OpenUrl", "title": "View PR", - "url": "'"$PR_URL"'" + "url": "$PR_URL" } ] } } ] - }' $TEAMS_WEBHOOK_URL + }' "$TEAMS_WEBHOOK_URL" From 63c3e041eb571396aaf3d50d0387509ec2339b2d Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 13:09:49 -0400 Subject: [PATCH 04/17] Run notify-teams on re-open of PR. --- .github/workflows/notify-teams.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 81424cd0..91cd2232 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -2,7 +2,7 @@ name: Notify Teams on PR Creation on: pull_request: - types: [opened] + types: [opened, reopened] jobs: notify: From f8d669e8582319c59331760c9825db8705b26980 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 13:38:58 -0400 Subject: [PATCH 05/17] Dynamically add github information (bug fix) --- .github/workflows/notify-teams.yml | 97 +++++++++++++++--------------- 1 file changed, 50 insertions(+), 47 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 91cd2232..35586ced 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -9,51 +9,54 @@ jobs: runs-on: ubuntu-latest steps: - - name: Send notification to Teams channel - env: - TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} - PR_TITLE: ${{ github.event.pull_request.title }} - PR_URL: ${{ github.event.pull_request.html_url }} - PR_BODY: ${{ github.event.pull_request.body }} - run: | - # Send an Adaptive Card to Teams with attachments - curl -H 'Content-Type: application/json' -d '{ - "type": "message", - "attachments": [ - { - "contentType": "application/vnd.microsoft.card.adaptive", - "content": { - "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", - "type": "AdaptiveCard", - "version": "1.4", - "body": [ - { - "type": "TextBlock", - "size": "Large", - "weight": "Bolder", - "text": "New Pull Request Created", - "horizontalAlignment": "Center" - }, - { - "type": "TextBlock", - "text": "**Title:** $PR_TITLE", - "wrap": true, - "separator": true - }, - { - "type": "TextBlock", - "text": "**Description:** $PR_BODY", - "wrap": true - } - ], - "actions": [ - { - "type": "Action.OpenUrl", - "title": "View PR", - "url": "$PR_URL" - } - ] - } + - name: Send notification to Teams channel + env: + TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_BODY: ${{ github.event.pull_request.body }} + run: | + JSON_PAYLOAD=$(cat <<-EOF + { + "type": "message", + "attachments": [ + { + "contentType": "application/vnd.microsoft.card.adaptive", + "content": { + "\$schema": "https://adaptivecards.io/schemas/adaptive-card.json", + "type": "AdaptiveCard", + "version": "1.4", + "body": [ + { + "type": "TextBlock", + "size": "Large", + "weight": "Bolder", + "text": "New Pull Request Created", + "horizontalAlignment": "Center" + }, + { + "type": "TextBlock", + "text": "**Title:** ${PR_TITLE}", + "wrap": true, + "separator": true + }, + { + "type": "TextBlock", + "text": "**Description:** ${PR_BODY}", + "wrap": true + } + ], + "actions": [ + { + "type": "Action.OpenUrl", + "title": "View PR", + "url": "${PR_URL}" + } + ] } - ] - }' "$TEAMS_WEBHOOK_URL" + } + ] + } + EOF + ) + curl -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$TEAMS_WEBHOOK_URL" From 1457e3f48522d705f30ec10f7be61b01f993485b Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 13:46:19 -0400 Subject: [PATCH 06/17] Use jq to create a properly escaped body --- .github/workflows/notify-teams.yml | 85 +++++++++++++++--------------- 1 file changed, 43 insertions(+), 42 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 35586ced..d08b99f9 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -16,47 +16,48 @@ jobs: PR_URL: ${{ github.event.pull_request.html_url }} PR_BODY: ${{ github.event.pull_request.body }} run: | - JSON_PAYLOAD=$(cat <<-EOF - { - "type": "message", - "attachments": [ - { - "contentType": "application/vnd.microsoft.card.adaptive", - "content": { - "\$schema": "https://adaptivecards.io/schemas/adaptive-card.json", - "type": "AdaptiveCard", - "version": "1.4", - "body": [ - { - "type": "TextBlock", - "size": "Large", - "weight": "Bolder", - "text": "New Pull Request Created", - "horizontalAlignment": "Center" - }, - { - "type": "TextBlock", - "text": "**Title:** ${PR_TITLE}", - "wrap": true, - "separator": true - }, - { - "type": "TextBlock", - "text": "**Description:** ${PR_BODY}", - "wrap": true - } - ], - "actions": [ - { - "type": "Action.OpenUrl", - "title": "View PR", - "url": "${PR_URL}" - } - ] + JSON_PAYLOAD=$(jq -n \ + --arg title "$PR_TITLE" \ + --arg url "$PR_URL" \ + --arg body "$PR_BODY" \ + '{ + type: "message", + attachments: [ + { + contentType: "application/vnd.microsoft.card.adaptive", + content: { + "$schema": "https://adaptivecards.io/schemas/adaptive-card.json", + type: "AdaptiveCard", + version: "1.4", + body: [ + { + type: "TextBlock", + size: "Large", + weight: "Bolder", + text: "New Pull Request Created", + horizontalAlignment: "Center" + }, + { + type: "TextBlock", + text: ("**Title:** " + $title), + wrap: true, + separator: true + }, + { + type: "TextBlock", + text: ("**Description:** " + $body), + wrap: true + } + ], + actions: [ + { + type: "Action.OpenUrl", + title: "View PR", + url: $url + } + ] + } } - } - ] - } - EOF - ) + ] + }') curl -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$TEAMS_WEBHOOK_URL" From 9f2f93bd5c01fedda5ffe707bec1b2ad3a352a1b Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 13:59:44 -0400 Subject: [PATCH 07/17] Downgrade to AdaptiveCard v1.2 --- .github/workflows/notify-teams.yml | 102 ++++++++++++++--------------- 1 file changed, 51 insertions(+), 51 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index d08b99f9..7896f38e 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -9,55 +9,55 @@ jobs: runs-on: ubuntu-latest steps: - - name: Send notification to Teams channel - env: - TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} - PR_TITLE: ${{ github.event.pull_request.title }} - PR_URL: ${{ github.event.pull_request.html_url }} - PR_BODY: ${{ github.event.pull_request.body }} - run: | - JSON_PAYLOAD=$(jq -n \ - --arg title "$PR_TITLE" \ - --arg url "$PR_URL" \ - --arg body "$PR_BODY" \ - '{ - type: "message", - attachments: [ - { - contentType: "application/vnd.microsoft.card.adaptive", - content: { - "$schema": "https://adaptivecards.io/schemas/adaptive-card.json", - type: "AdaptiveCard", - version: "1.4", - body: [ - { - type: "TextBlock", - size: "Large", - weight: "Bolder", - text: "New Pull Request Created", - horizontalAlignment: "Center" - }, - { - type: "TextBlock", - text: ("**Title:** " + $title), - wrap: true, - separator: true - }, - { - type: "TextBlock", - text: ("**Description:** " + $body), - wrap: true - } - ], - actions: [ - { - type: "Action.OpenUrl", - title: "View PR", - url: $url - } - ] + - name: Send notification to Teams channel + env: + TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_BODY: ${{ github.event.pull_request.body }} + run: | + JSON_PAYLOAD=$(jq -n \ + --arg title "$PR_TITLE" \ + --arg url "$PR_URL" \ + --arg body "$PR_BODY" \ + '{ + type: "message", + attachments: [ + { + contentType: "application/vnd.microsoft.card.adaptive", + content: { + "$schema": "https://adaptivecards.io/schemas/adaptive-card.json", + type: "AdaptiveCard", + version: "1.2", + body: [ + { + type: "TextBlock", + size: "Large", + weight: "Bolder", + text: "New Pull Request Created", + horizontalAlignment: "Center" + }, + { + type: "TextBlock", + text: "Title: " + $title, + wrap: true, + separator: true + }, + { + type: "TextBlock", + text: "Description: " + $body, + wrap: true + } + ], + actions: [ + { + type: "Action.OpenUrl", + title: "View PR", + url: $url + } + ] + } } - } - ] - }') - curl -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$TEAMS_WEBHOOK_URL" + ] + }') + curl -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$TEAMS_WEBHOOK_URL" From 010d37fc0e3929fa88326846a3903e6f717b6745 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:04:41 -0400 Subject: [PATCH 08/17] Tweak concatanation --- .github/workflows/notify-teams.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 7896f38e..a36ed9d0 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -39,13 +39,13 @@ jobs: }, { type: "TextBlock", - text: "Title: " + $title, + text: (["Title: ", $title] | join("")), wrap: true, separator: true }, { type: "TextBlock", - text: "Description: " + $body, + text: (["Description: ", $body] | join("")), wrap: true } ], From a967fd40bc77d768ec6cdfe7671f96d800178363 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:12:47 -0400 Subject: [PATCH 09/17] Remove type:message to try to avoid link wrapping --- .github/workflows/notify-teams.yml | 101 ++++++++++++++--------------- 1 file changed, 50 insertions(+), 51 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index a36ed9d0..366af694 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -9,55 +9,54 @@ jobs: runs-on: ubuntu-latest steps: - - name: Send notification to Teams channel - env: - TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} - PR_TITLE: ${{ github.event.pull_request.title }} - PR_URL: ${{ github.event.pull_request.html_url }} - PR_BODY: ${{ github.event.pull_request.body }} - run: | - JSON_PAYLOAD=$(jq -n \ - --arg title "$PR_TITLE" \ - --arg url "$PR_URL" \ - --arg body "$PR_BODY" \ - '{ - type: "message", - attachments: [ - { - contentType: "application/vnd.microsoft.card.adaptive", - content: { - "$schema": "https://adaptivecards.io/schemas/adaptive-card.json", - type: "AdaptiveCard", - version: "1.2", - body: [ - { - type: "TextBlock", - size: "Large", - weight: "Bolder", - text: "New Pull Request Created", - horizontalAlignment: "Center" - }, - { - type: "TextBlock", - text: (["Title: ", $title] | join("")), - wrap: true, - separator: true - }, - { - type: "TextBlock", - text: (["Description: ", $body] | join("")), - wrap: true - } - ], - actions: [ - { - type: "Action.OpenUrl", - title: "View PR", - url: $url - } - ] - } + - name: Send notification to Teams channel + env: + TEAMS_WEBHOOK_URL: ${{ secrets.TEAMS_WEBHOOK_URL }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + PR_BODY: ${{ github.event.pull_request.body }} + run: | + JSON_PAYLOAD=$(jq -n \ + --arg title "$PR_TITLE" \ + --arg url "$PR_URL" \ + --arg body "$PR_BODY" \ + '{ + attachments: [ + { + contentType: "application/vnd.microsoft.card.adaptive", + content: { + "$schema": "https://adaptivecards.io/schemas/adaptive-card.json", + type: "AdaptiveCard", + version: "1.2", + body: [ + { + type: "TextBlock", + size: "Large", + weight: "Bolder", + text: "New Pull Request Created", + horizontalAlignment: "Center" + }, + { + type: "TextBlock", + text: (["Title: ", $title] | join("")), + wrap: true, + separator: true + }, + { + type: "TextBlock", + text: (["Description: ", $body] | join("")), + wrap: true + } + ], + actions: [ + { + type: "Action.OpenUrl", + title: "View PR", + url: $url + } + ] } - ] - }') - curl -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$TEAMS_WEBHOOK_URL" + } + ] + }') + curl -H "Content-Type: application/json" -d "$JSON_PAYLOAD" "$TEAMS_WEBHOOK_URL" From e2b7bd06f4694484fda37783b177d2ee0a672b10 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:16:50 -0400 Subject: [PATCH 10/17] Add a text-based link to the PR --- .github/workflows/notify-teams.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 366af694..8deaef2c 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -27,7 +27,7 @@ jobs: content: { "$schema": "https://adaptivecards.io/schemas/adaptive-card.json", type: "AdaptiveCard", - version: "1.2", + version: "1.0", body: [ { type: "TextBlock", @@ -46,6 +46,13 @@ jobs: type: "TextBlock", text: (["Description: ", $body] | join("")), wrap: true + }, + { + type: "TextBlock", + text: (["View PR: ", $url] | join("")), + wrap: true, + spacing: "Medium", + isSubtle: true } ], actions: [ From 1f6e720a967e2cdffbac9ed041607851b3591e6d Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:23:47 -0400 Subject: [PATCH 11/17] Try to hyperlink PR, remove button --- .github/workflows/notify-teams.yml | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 8deaef2c..91ae85b9 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -38,28 +38,20 @@ jobs: }, { type: "TextBlock", - text: (["Title: ", $title] | join("")), + text: (["**Title:** ", $title] | join("")), wrap: true, separator: true }, { type: "TextBlock", - text: (["Description: ", $body] | join("")), + text: (["**Description:** ", $body] | join("")), wrap: true }, { type: "TextBlock", - text: (["View PR: ", $url] | join("")), + text: (["[View PR](", $url, ")"] | join("")), wrap: true, - spacing: "Medium", - isSubtle: true - } - ], - actions: [ - { - type: "Action.OpenUrl", - title: "View PR", - url: $url + spacing: "Medium" } ] } From 6df3b389831862a5ea019cd8ce3170d47c17c6d7 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:28:26 -0400 Subject: [PATCH 12/17] Remove button, set hyperlink back to text --- .github/workflows/notify-teams.yml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 91ae85b9..29de1b07 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -38,22 +38,25 @@ jobs: }, { type: "TextBlock", - text: (["**Title:** ", $title] | join("")), + text: (["Title: ", $title] | join("")), wrap: true, separator: true }, { type: "TextBlock", - text: (["**Description:** ", $body] | join("")), - wrap: true + text: (["Description: ", $body] | join("")), + wrap: true, + separator: true }, { type: "TextBlock", - text: (["[View PR](", $url, ")"] | join("")), + text: (["View PR: ", $url] | join("")), wrap: true, - spacing: "Medium" + spacing: "Medium", + isSubtle: true, + separator: true } - ] + ], } } ] From 572d1dce3179249aa4e69f66ffc7371a57d6eaab Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:39:58 -0400 Subject: [PATCH 13/17] Remove ability to hyperlink on PR bodies --- .github/workflows/notify-teams.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 29de1b07..ef6e9c61 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -44,7 +44,7 @@ jobs: }, { type: "TextBlock", - text: (["Description: ", $body] | join("")), + text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; "\(.1)"))] | join("")), wrap: true, separator: true }, From eb9b85b5eba492a51425ab5a80ea062cc0179ddd Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:43:10 -0400 Subject: [PATCH 14/17] Correct gsub substitution for hyperlinks --- .github/workflows/notify-teams.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index ef6e9c61..42d5904d 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -44,7 +44,7 @@ jobs: }, { type: "TextBlock", - text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; "\(.1)"))] | join("")), + text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; "\($1)"))] | join("")), wrap: true, separator: true }, From 36802ebe8b0961b03ee142951aeb9287272ebde0 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:46:39 -0400 Subject: [PATCH 15/17] Use 'captures' in gsub operation --- .github/workflows/notify-teams.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 42d5904d..311615e4 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -44,7 +44,7 @@ jobs: }, { type: "TextBlock", - text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; "\($1)"))] | join("")), + text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; (.captures[0])))] | join("")), wrap: true, separator: true }, @@ -56,7 +56,7 @@ jobs: isSubtle: true, separator: true } - ], + ] } } ] From e9e5313d02c02553c841ba540662a91e8ead0925 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:49:50 -0400 Subject: [PATCH 16/17] Add .string to captures --- .github/workflows/notify-teams.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 311615e4..3a99e831 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -44,7 +44,7 @@ jobs: }, { type: "TextBlock", - text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; (.captures[0])))] | join("")), + text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; (.captures[0].string)))] | join("")), wrap: true, separator: true }, From 1338c47fbb3aadd2fac36afdfea6ebfbf4041d11 Mon Sep 17 00:00:00 2001 From: Janell-Huyck Date: Mon, 7 Apr 2025 14:54:07 -0400 Subject: [PATCH 17/17] Use sed to preprocess PR body --- .github/workflows/notify-teams.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/notify-teams.yml b/.github/workflows/notify-teams.yml index 3a99e831..f042f68a 100644 --- a/.github/workflows/notify-teams.yml +++ b/.github/workflows/notify-teams.yml @@ -16,10 +16,12 @@ jobs: PR_URL: ${{ github.event.pull_request.html_url }} PR_BODY: ${{ github.event.pull_request.body }} run: | + # Remove markdown link formatting: convert [text](URL) to just text. + TRANSFORMED_BODY=$(echo "$PR_BODY" | sed -E 's/\[([^]]+)\]\([^)]*\)/\1/g') JSON_PAYLOAD=$(jq -n \ --arg title "$PR_TITLE" \ --arg url "$PR_URL" \ - --arg body "$PR_BODY" \ + --arg body "$TRANSFORMED_BODY" \ '{ attachments: [ { @@ -44,7 +46,7 @@ jobs: }, { type: "TextBlock", - text: (["Description: ", ($body | gsub("\\[([^]]+)\\]\\(([^)]+)\\)"; (.captures[0].string)))] | join("")), + text: (["Description: ", $body] | join("")), wrap: true, separator: true },