Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update instructions after slack action v2 update #658

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 16 additions & 32 deletions actions/send-slack-message/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,6 @@ See the docs for the [slackapi/slack-github-action workflow](https://github.com/

<!-- x-release-please-start-version -->

```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/[email protected]
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/[email protected]
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:
Expand All @@ -38,9 +17,10 @@ jobs:
id: slack
uses: grafana/shared-workflows/actions/[email protected]
with:
channel-id: "Channel Name or ID"
method: chat.postMessage
payload: |
{
"channel": "Channel ID",
"text": "Deployment started (In Progress)",
"attachments": [
{
Expand All @@ -60,9 +40,11 @@ jobs:
- name: Update Slack Message via Payload
uses: grafana/shared-workflows/actions/[email protected]
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": [
{
Expand All @@ -78,7 +60,6 @@ jobs:
}
]
}

update-ts: ${{ steps.slack.outputs.ts }}
```

Expand All @@ -92,17 +73,20 @@ jobs:
id: slack
uses: grafana/shared-workflows/actions/[email protected]
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/[email protected]
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)"
}
Expand All @@ -112,12 +96,12 @@ jobs:

## Inputs

| 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. |
| 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

Expand Down
15 changes: 7 additions & 8 deletions actions/send-slack-message/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand All @@ -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 }}
Loading