From 9d8a0d96464eb14cda03dfbd06657b15c706cfd4 Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 10:30:37 -0500 Subject: [PATCH 1/8] Add slack notification action --- notify-slack/action.yml | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 notify-slack/action.yml diff --git a/notify-slack/action.yml b/notify-slack/action.yml new file mode 100644 index 0000000..44f15bf --- /dev/null +++ b/notify-slack/action.yml @@ -0,0 +1,41 @@ +name: 'Slack Notification' +description: 'Send notifications to Slack' +inputs: + slack-webhook: + description: 'Slack webhook URL' + required: true + slack-username: + description: 'Username to display in the message' + required: true + slack-channel: + description: 'Slack channel to post the message' + required: true + title: + description: 'Message title' + required: true + text: + description: 'Message text' + required: true + color: + description: 'Color of the message' + required: false + default: 'Good' + +runs: + using: composite + steps: + - name: Notify Slack Channel + shell: bash + run: | + curl "${{ inputs.slack-webhook }}" "-XPOST -H 'Content-Type: application/json'" + --data '{ + "username": "${{ inputs.slack-username }}", + "channel": "${{ inputs.slack-channel }}", + "attachments": [ + { + "title": "${{ inputs.title }}", + "text": "${{ inputs.text }}", + "color": "${{ inputs.color }}" + } + ] + }' From bb64319e402cfc3c6362bcc2f4d00e313125e99b Mon Sep 17 00:00:00 2001 From: Anh Tu Pham Date: Thu, 7 Mar 2024 15:58:21 +0000 Subject: [PATCH 2/8] [check-spelling] Update metadata Update for https://github.com/GarnerCorp/build-actions/actions/runs/8191067924/attempts/1 Accepted in https://github.com/GarnerCorp/build-actions/pull/1#issuecomment-1983829809 Signed-off-by: check-spelling-bot on-behalf-of: @check-spelling --- .github/actions/spelling/expect.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 5fe7108..6f36417 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -24,3 +24,4 @@ temurin tojson usr workflows +XPOST From dc7e9ca85c0ede5c5a5f4c388cc27c76357dd9ac Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 11:06:36 -0500 Subject: [PATCH 3/8] Force HTTP1.1 --- notify-slack/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notify-slack/action.yml b/notify-slack/action.yml index 44f15bf..617a60d 100644 --- a/notify-slack/action.yml +++ b/notify-slack/action.yml @@ -19,7 +19,7 @@ inputs: color: description: 'Color of the message' required: false - default: 'Good' + default: 'good' runs: using: composite @@ -27,7 +27,7 @@ runs: - name: Notify Slack Channel shell: bash run: | - curl "${{ inputs.slack-webhook }}" "-XPOST -H 'Content-Type: application/json'" + curl "${{ inputs.slack-webhook }}" "-XPOST -H 'Content-Type: application/json'" --http1.1 --data '{ "username": "${{ inputs.slack-username }}", "channel": "${{ inputs.slack-channel }}", From 78ffe661fb10f1d1aaf54ae876cd9061717a23b3 Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 11:09:53 -0500 Subject: [PATCH 4/8] Line indent --- notify-slack/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify-slack/action.yml b/notify-slack/action.yml index 617a60d..0ba19b7 100644 --- a/notify-slack/action.yml +++ b/notify-slack/action.yml @@ -27,7 +27,7 @@ runs: - name: Notify Slack Channel shell: bash run: | - curl "${{ inputs.slack-webhook }}" "-XPOST -H 'Content-Type: application/json'" --http1.1 + curl "${{ inputs.slack-webhook }}" "-XPOST -H 'Content-Type: application/json'" --http1.1 \ --data '{ "username": "${{ inputs.slack-username }}", "channel": "${{ inputs.slack-channel }}", From fc3cbf26b71bd9926519adf1679af8e27ca2cd47 Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 11:21:21 -0500 Subject: [PATCH 5/8] Fix the bad curl command --- notify-slack/action.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notify-slack/action.yml b/notify-slack/action.yml index 0ba19b7..3dc94dc 100644 --- a/notify-slack/action.yml +++ b/notify-slack/action.yml @@ -27,15 +27,15 @@ runs: - name: Notify Slack Channel shell: bash run: | - curl "${{ inputs.slack-webhook }}" "-XPOST -H 'Content-Type: application/json'" --http1.1 \ + curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" --data '{ "username": "${{ inputs.slack-username }}", - "channel": "${{ inputs.slack-channel }}", + "channel": "${{ inputs.slack-channel }}", "attachments": [ - { + { "title": "${{ inputs.title }}", "text": "${{ inputs.text }}", "color": "${{ inputs.color }}" } ] - }' + }' From 8687bc8731b345fc208ad9ea92bf553085e2e342 Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 11:22:31 -0500 Subject: [PATCH 6/8] Try -d --- notify-slack/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notify-slack/action.yml b/notify-slack/action.yml index 3dc94dc..e0d4094 100644 --- a/notify-slack/action.yml +++ b/notify-slack/action.yml @@ -28,7 +28,7 @@ runs: shell: bash run: | curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" - --data '{ + -d '{ "username": "${{ inputs.slack-username }}", "channel": "${{ inputs.slack-channel }}", "attachments": [ From 500c97c0b6b2ccb501caefff71c6fc401fc22ed1 Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 11:23:22 -0500 Subject: [PATCH 7/8] newline --- notify-slack/action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/notify-slack/action.yml b/notify-slack/action.yml index e0d4094..c896c47 100644 --- a/notify-slack/action.yml +++ b/notify-slack/action.yml @@ -27,8 +27,8 @@ runs: - name: Notify Slack Channel shell: bash run: | - curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" - -d '{ + curl "${{ inputs.slack-webhook }}" -X POST -H "Content-Type: application/json" \ + --data '{ "username": "${{ inputs.slack-username }}", "channel": "${{ inputs.slack-channel }}", "attachments": [ From 5c3d018eb5d55fe12ed4815aafe36f97aa6e245b Mon Sep 17 00:00:00 2001 From: Tu Pham Date: Thu, 7 Mar 2024 11:55:16 -0500 Subject: [PATCH 8/8] Remove XPOST as an expected word --- .github/actions/spelling/expect.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 6f36417..5fe7108 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -24,4 +24,3 @@ temurin tojson usr workflows -XPOST