From 28f130f394adf2b832ab83fbdeb8cd05077a1e83 Mon Sep 17 00:00:00 2001 From: dsotirakis Date: Tue, 17 Dec 2024 13:10:18 +0200 Subject: [PATCH 1/4] Update instructions --- actions/send-slack-message/README.md | 44 ++++++++------------------ actions/send-slack-message/action.yaml | 15 ++++----- 2 files changed, 21 insertions(+), 38 deletions(-) diff --git a/actions/send-slack-message/README.md b/actions/send-slack-message/README.md index 8a9e6b433..bdc035cb6 100644 --- a/actions/send-slack-message/README.md +++ b/actions/send-slack-message/README.md @@ -7,27 +7,6 @@ See the docs for the [slackapi/slack-github-action workflow](https://github.com/ -```yaml -name: Send And Update a Slack plain text message -jobs: - send-and-update-slack-message: - name: Send and update Slack message - steps: - - name: Send Slack Message - id: slack - uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 - with: - channel-id: "Channel Name or ID" - slack-message: "We are testing, testing, testing all day long" - - - name: Update Slack Message - uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 - with: - channel-id: ${{ steps.slack.outputs.channel_id }} # Channel ID is required when updating a message - slack-message: "This is the updated message" - update-ts: ${{ steps.slack.outputs.ts }} -``` - ```yaml name: Send And Update a Slack message using JSON payload jobs: @@ -38,9 +17,10 @@ jobs: id: slack uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 with: - channel-id: "Channel Name or ID" + method: chat.postMessage payload: | { + "channel": "Channel ID", "text": "Deployment started (In Progress)", "attachments": [ { @@ -60,9 +40,11 @@ jobs: - name: Update Slack Message via Payload uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 with: - channel-id: ${{ steps.slack.outputs.channel_id }} + method: post.update + payload-templated: true payload: | { + "channel": ${{ steps.slack.outputs.channel_id }}, "text": "Deployment finished (Completed)", "attachments": [ { @@ -78,7 +60,6 @@ jobs: } ] } - update-ts: ${{ steps.slack.outputs.ts }} ``` @@ -92,17 +73,20 @@ jobs: id: slack uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 with: - channel-id: "Channel Name or ID" + method: chat.postMessage payload: | { + "channel": "Channel ID", "text": "Deployment started (In Progress)" } - name: Respond to Slack Message uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 with: - channel-id: ${{ steps.slack.outputs.channel_id }} + method: chat.postMessage + payload-templated: true payload: | { + "channel": "Channel ID", "thread_ts": "${{ steps.slack.outputs.ts }}", "text": "Deployment finished (Completed)" } @@ -114,10 +98,10 @@ jobs: | Name | Type | Description | | --------------- | ------ | ----------------------------------------------------------------------------------------- | -| `channel-id` | String | Name or ID of the channel to send to. | -| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | -| `slack-message` | String | Plain text message to send. Use `payload` or `slack-message`, but not both. | -| `update-ts` | String | The timestamp of a previous message posted. Used to update or reply to previous messages. | +| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | | +| `method` | String | The Slack API method to call. | +| `payload-templated` | String | The Slack API method to call. | +| `update-ts` | String | To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true. | ## Outputs diff --git a/actions/send-slack-message/action.yaml b/actions/send-slack-message/action.yaml index f48580416..9528b2790 100644 --- a/actions/send-slack-message/action.yaml +++ b/actions/send-slack-message/action.yaml @@ -2,18 +2,18 @@ name: Send Slack Message description: Composite action to send a Slack message inputs: - channel-id: - description: "Name or ID of the channel to send to" - required: true payload: description: "JSON payload to send. Use `payload` or `slack-message`, but not both" required: false - slack-message: - description: "Plain text message to send. Use `payload` or `slack-message`, but not both" - required: false update-ts: description: "The timestamp of a previous message posted. Used to update or reply to existing messages" required: false + method: + description: "The Slack API method to call" + required: true + payload-templated: + description: "To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true" + required: false outputs: time: value: ${{ steps.send-slack-message.outputs.time }} @@ -40,9 +40,8 @@ runs: id: send-slack-message uses: slackapi/slack-github-action@485a9d42d3a73031f12ec201c457e2162c45d02d # v2.0.0 with: + payload-templated: ${{ inputs.payload-templated }} method: chat.postMessage - channel: ${{ inputs.channel-id }} payload: ${{ inputs.payload }} - slack-message: ${{ inputs.slack-message }} update-ts: ${{ inputs.update-ts }} token: ${{ env.SLACK_BOT_TOKEN }} From 8826653b9764a109e0953f9213bdac67ef0b3a73 Mon Sep 17 00:00:00 2001 From: dsotirakis Date: Tue, 17 Dec 2024 13:15:28 +0200 Subject: [PATCH 2/4] Prettify --- actions/send-slack-message/README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/actions/send-slack-message/README.md b/actions/send-slack-message/README.md index bdc035cb6..261eed417 100644 --- a/actions/send-slack-message/README.md +++ b/actions/send-slack-message/README.md @@ -73,7 +73,7 @@ jobs: id: slack uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 with: - method: chat.postMessage + method: chat.postMessage payload: | { "channel": "Channel ID", @@ -82,7 +82,7 @@ jobs: - name: Respond to Slack Message uses: grafana/shared-workflows/actions/send-slack-message@send-slack-message-v2.0.0 with: - method: chat.postMessage + method: chat.postMessage payload-templated: true payload: | { @@ -96,12 +96,12 @@ jobs: ## Inputs -| Name | Type | Description | -| --------------- | ------ | ----------------------------------------------------------------------------------------- | -| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | | -| `method` | String | The Slack API method to call. | -| `payload-templated` | String | The Slack API method to call. | -| `update-ts` | String | To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true. | +| Name | Type | Description | +| ------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | --- | +| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | | +| `method` | String | The Slack API method to call. | +| `payload-templated` | String | The Slack API method to call. | +| `update-ts` | String | To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true. | ## Outputs From debb17239aee8fba5fee12a9912832ad7130bb35 Mon Sep 17 00:00:00 2001 From: dsotirakis Date: Tue, 17 Dec 2024 16:13:43 +0200 Subject: [PATCH 3/4] Fix broken markdown table --- actions/send-slack-message/README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/actions/send-slack-message/README.md b/actions/send-slack-message/README.md index 261eed417..653b633e4 100644 --- a/actions/send-slack-message/README.md +++ b/actions/send-slack-message/README.md @@ -96,12 +96,12 @@ jobs: ## Inputs -| Name | Type | Description | -| ------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | --- | -| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | | -| `method` | String | The Slack API method to call. | -| `payload-templated` | String | The Slack API method to call. | -| `update-ts` | String | To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true. | +| Name | Type | Description | +| ------------------- | ------ | --------------------------------------------------------------------------- | +| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | +| `method` | String | The Slack API method to call. | +| `payload-templated` | String | To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true. | +| `update-ts` | String | The timestamp of the message to update. | ## Outputs From 99fab5d3ff1c8c8e10479645bd8161dfba16692c Mon Sep 17 00:00:00 2001 From: dsotirakis Date: Wed, 18 Dec 2024 10:57:02 +0200 Subject: [PATCH 4/4] Prettify --- actions/send-slack-message/README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/actions/send-slack-message/README.md b/actions/send-slack-message/README.md index 653b633e4..ab4f308bc 100644 --- a/actions/send-slack-message/README.md +++ b/actions/send-slack-message/README.md @@ -96,12 +96,12 @@ jobs: ## Inputs -| Name | Type | Description | -| ------------------- | ------ | --------------------------------------------------------------------------- | -| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | -| `method` | String | The Slack API method to call. | +| Name | Type | Description | +| ------------------- | ------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | +| `payload` | String | JSON payload to send. Use `payload` or `slack-message`, but not both. | +| `method` | String | The Slack API method to call. | | `payload-templated` | String | To replace templated variables provided from the step env or default GitHub event context and payload, set the payload-templated variable to true. | -| `update-ts` | String | The timestamp of the message to update. | +| `update-ts` | String | The timestamp of the message to update. | ## Outputs