docs: streamlines doc structure (#590)

This commit is contained in:
Luke Russell
2026-04-17 12:49:17 -07:00
committed by GitHub
parent 093434f78f
commit 7ce931db3e
21 changed files with 347 additions and 449 deletions
+14 -77
View File
@@ -1,78 +1,15 @@
[
{
"type": "doc",
"id": "tools/slack-github-action/slack-github-action",
"label": "Slack GitHub Action",
"className": "sidebar-title"
},
{ "type": "html", "value": "<hr>" },
"tools/slack-github-action/sending-variables",
{
"type": "category",
"label": "Sending techniques",
"collapsed": false,
"link": {
"type": "doc",
"id": "tools/slack-github-action/sending-techniques/sending-techniques"
},
"items": [
"tools/slack-github-action/sending-techniques/sending-techniques",
{
"type": "category",
"label": "Sending data via a webhook to start a Slack workflow",
"link": {
"type": "doc",
"id": "tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/sending-data-webhook-slack-workflow"
},
"items": [
"tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/sending-data-webhook-slack-workflow",
"tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/format-generated-files",
"tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/post-release-announcements",
"tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/update-a-channel-topic"
]
},
{
"type": "category",
"label": "Sending data using a Slack API method",
"link": {
"type": "doc",
"id": "tools/slack-github-action/sending-techniques/sending-data-slack-api-method/sending-data-slack-api-method"
},
"items": [
"tools/slack-github-action/sending-techniques/sending-data-slack-api-method/sending-data-slack-api-method",
"tools/slack-github-action/sending-techniques/sending-data-slack-api-method/direct-message-author",
"tools/slack-github-action/sending-techniques/sending-data-slack-api-method/invite-usergroup-to-channel"
]
},
{
"type": "category",
"label": "Sending data as a message with a Slack incoming webhook URL",
"link": {
"type": "doc",
"id": "tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/sending-data-slack-incoming-webhook"
},
"items": [
"tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/sending-data-slack-incoming-webhook",
"tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/post-inline-text-message",
"tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/post-inline-block-message",
"tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/post-blocks-found-in-file"
]
},
{
"type": "category",
"label": "Running Slack CLI commands",
"link": {
"type": "doc",
"id": "tools/slack-github-action/sending-techniques/running-slack-cli-commands/running-slack-cli-commands"
},
"items": [
"tools/slack-github-action/sending-techniques/running-slack-cli-commands/running-slack-cli-commands",
"tools/slack-github-action/sending-techniques/running-slack-cli-commands/deploy-an-app",
"tools/slack-github-action/sending-techniques/running-slack-cli-commands/validate-a-manifest",
"tools/slack-github-action/sending-techniques/running-slack-cli-commands/manage-collaborators"
]
}
]
},
"tools/slack-github-action/additional-configurations"
]
{
"type": "doc",
"id": "tools/slack-github-action/slack-github-action",
"label": "Slack GitHub Action",
"className": "sidebar-title"
},
{ "type": "html", "value": "<hr>" },
"tools/slack-github-action/gathering-variables",
"tools/slack-github-action/sending-data-webhook-slack-workflow",
"tools/slack-github-action/sending-data-slack-api-method",
"tools/slack-github-action/sending-data-slack-incoming-webhook",
"tools/slack-github-action/running-slack-cli-commands",
"tools/slack-github-action/additional-configurations"
]
-17
View File
@@ -21,23 +21,6 @@ The `errors` option defaults to `false` so failed requests do not cause the step
Invalid inputs to the GitHub Action, such as not including a payload, will always cause the GitHub step to fail.
## Flattening nested payloads
Variables and data provided in the payload might contain nested fields that need to be flattened before being sent with a [webhook trigger](/tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow) to match the expected input format of [Workflow Builder](https://slack.com/features/workflow-automation).
The `payload-delimiter` option will flatten the input payload using the provided delimiter and will also make values stringified:
```yaml
- name: Flatten the default GitHub payload
uses: slackapi/[email protected]
with:
payload-delimiter: "_"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
```
Reference to the flattening implementation is available for exploration from within the [`flat`](https://www.npmjs.com/package/flat) package.
## Parsing templated variables
Additional variables provided in the GitHub event [context](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L6) and event [payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads) can be used to replace templated variables in the input payload with the `payload-templated` option:
@@ -1,6 +1,6 @@
# Sending variables
# Gathering variables
There are different [techniques to send data](/tools/slack-github-action/sending-techniques) into Slack and whichever one is chosen will require a certain set of customized inputs, as described later.
There are different techniques to send data into Slack and whichever one is chosen will require a certain set of customized inputs, as described later.
You can provide data to send to Slack from this GitHub Action and either source:
@@ -1,7 +1,3 @@
---
sidebar_label: Overview
---
# Running Slack CLI commands
The Slack CLI technique installs and runs [Slack CLI](/tools/slack-cli/) commands directly from a GitHub Actions workflow.
@@ -82,6 +78,17 @@ steps:
token: ${{ secrets.SLACK_SERVICE_TOKEN }}
```
<details>
<summary><strong>Workflow: Validate a manifest</strong></summary>
This workflow validates the app manifest on pull requests to catch configuration issues early.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_4_Slack_CLI_Command/manifest.yml
```
</details>
### Deploy an app with a service token
```yaml
@@ -93,8 +100,29 @@ steps:
token: ${{ secrets.SLACK_SERVICE_TOKEN }}
```
## Example workflows
<details>
<summary><strong>Workflow: Deploy an app</strong></summary>
* [**Deploy an app**](/tools/slack-github-action/sending-techniques/running-slack-cli-commands/deploy-an-app): Deploy to Slack on push to the main branch.
* [**Validate a manifest**](/tools/slack-github-action/sending-techniques/running-slack-cli-commands/validate-a-manifest): Check the app manifest on pull requests.
* [**Manage collaborators**](/tools/slack-github-action/sending-techniques/running-slack-cli-commands/manage-collaborators): Add or remove an app collaborator using CLI and API techniques together.
This workflow deploys a Slack app when changes are pushed to the main branch. It uses a service token to authenticate the deploy command.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_4_Slack_CLI_Command/deploy.yml
```
</details>
### Manage collaborators
<details>
<summary><strong>Workflow: Manage collaborators</strong></summary>
This workflow adds or removes an app collaborator using a manually triggered workflow.
This example combines the Slack API technique ([`users.lookupByEmail`](https://docs.slack.dev/reference/methods/users.lookupByEmail), [`chat.postMessage`](https://docs.slack.dev/reference/methods/chat.postMessage)) with the CLI technique ([`collaborators add`](https://docs.slack.dev/tools/slack-cli/reference/commands/slack_collaborators_add)/[`remove`](https://docs.slack.dev/tools/slack-cli/reference/commands/slack_collaborators_remove)) to look up a user by email, update collaborators, and post a confirmation message.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_4_Slack_CLI_Command/collaborators.yml
```
</details>
@@ -1,7 +1,3 @@
---
sidebar_label: Overview
---
# Sending data using a Slack API method
A bot token or user token or [token of some other kind](/authentication/tokens) must be used to call one of [the Slack API methods](/reference/methods) with this technique.
@@ -139,7 +135,47 @@ Calling [a Slack API method](/reference/methods) with [`@slack/web-api`](/tools/
filename: "results-${{ github.sha }}.out"
```
## Expected outputs
The technique, like all Slack Github Action techniques, [outputs values](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs) that can be used as inputs in following steps of a GitHub workflow.
The following outputs are returned with each of the techniques:
| Output | Type | Description|
|---|---|---|
|`time` | `number` | The Unix [epoch time](https://en.wikipedia.org/wiki/Unix_time) that the step completed.
| `ok` | `boolean` | If the request completed with success.
| `response` | `string` | The [response](/apis/web-api/#responses) from the request as stringified JSON.
While these outputs are returned with certain Slack API methods:
| Output | Type | Description|
|---|---|---|
|`channel_id` | `string` | The [channel ID](/reference/objects/conversation-object) included in the response.
| `ts`| `string` | The [timestamp](/messaging/retrieving-messages#individual_messages) of the Slack event or message.
| `thread_ts` | `string` | The [timestamp](/messaging/retrieving-messages#individual_messages) of a parent Slack message with [threaded replies](/messaging/retrieving-messages#pulling_threads).
## Example workflows
- [**Direct message the author**](/tools/slack-github-action/sending-techniques/sending-data-slack-api-method/direct-message-author): Write to the Slack user with a matching email.
- [**Invite a usergroup to channel**](/tools/slack-github-action/sending-techniques/sending-data-slack-api-method/invite-usergroup-to-channel): Create a channel and invite members.
<details>
<summary><strong>Direct message the author</strong></summary>
This workflow sends a direct message to the user that pushed the most recent commits. It does so by grabbing the email of the pusher.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_2_Slack_API_Method/author.yml
```
</details>
<details>
<summary><strong>Invite a usergroup to channel</strong></summary>
This workflow creates a channel after a bug is reported and add members of a usergroup by chaining multiple Slack API method calls together.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_2_Slack_API_Method/invite.yml
```
</details>
@@ -1,7 +1,3 @@
---
sidebar_label: Overview
---
# Sending data as a message with a Slack incoming webhook URL
This technique uses this Action to post a message to a channel or direct message with [incoming webhooks](/messaging/sending-messages-using-incoming-webhooks) and a Slack app.
@@ -44,8 +40,57 @@ Add the collected webhook from above to a GitHub workflow and configure the step
text: "GitHub Action build result: ${{ job.status }}\n${{ github.event.pull_request.html_url || github.event.head_commit.url }}"
```
## Expected outputs
The technique, like all Slack Github Action techniques, [outputs values](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs) that can be used as inputs in following steps of a GitHub workflow.
The following outputs are returned with each of the techniques:
| Output | Type | Description|
|---|---|---|
|`time` | `number` | The Unix [epoch time](https://en.wikipedia.org/wiki/Unix_time) that the step completed.
| `ok` | `boolean` | If the request completed with success.
| `response` | `string` | The [response](/apis/web-api/#responses) from the request as stringified JSON.
## Example workflows
* [**Post an inline text message**](/tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/post-inline-text-message)
* [**Post an inline block message**](/tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/post-inline-block-message)
* [**Post blocks found in a file**](/tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/post-blocks-found-in-file)
<details>
<summary><strong>Post an inline text message</strong></summary>
This workflow uses incoming webhooks to post a plain text message.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/text.yml
```
</details>
<details>
<summary><strong>Post an inline block message</strong></summary>
This workflow uses incoming webhooks to post a message with Block Kit.
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/blocks.yml
```
</details>
<details>
<summary><strong>Post blocks found in a file</strong></summary>
This workflow uses file data when posting to an incoming webhook. It links to the GitHub Actions job in progress.
Payload file being sent
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/saved.data.json
```
### Workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/saved.gha.yml
```
</details>
+192
View File
@@ -0,0 +1,192 @@
# Sending data via a webhook to start a Slack workflow
:::info[This technique requires [a Slack paid plan](https://slack.com/pricing) to use Workflow Builder.]
:::
This technique sends data to Slack using a webhook to start a workflow created using Slack [Workflow Builder](https://slack.com/features/workflow-automation).
## Setup
Start in Slack to create a Slack workflow:
1. [Create a Slack workflow](https://slack.com/help/articles/360041352714-Build-a-workflow--Create-a-workflow-that-starts-outside-of-Slack) that starts from a webhook.
2. Copy the webhook URL and [add it as a repository secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) called `SLACK_WEBHOOK_URL`.
3. [Add this Action as a step](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps) to your GitHub workflow and provide an input payload to send to the webhook.
4. Configure your Slack workflow to use the payload variables sent from the GitHub Action. You can then update the steps of the Slack workflow to use these values in creative and clever ways.
The webhook URL will resemble something like so:
```txt
https://hooks.slack.com/triggers/T0123456789/3141592653589/c6e6c0d868b3054ca0f4611a5dbadaf
```
## Usage
Update the input payloads sent from this GitHub Action to your Slack workflow using the following options:
### Sending values from the default GitHub event context
In the example below, the default GitHub event [context](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L6) and event [payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads) associated with the job that started the GitHub workflow are sent to the provided webhook URL:
```yaml
- name: Send GitHub Action data to a Slack workflow
uses: slackapi/[email protected]
with:
payload-delimiter: "_"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
```
Accessing variables sent to [Workflow Builder](https://slack.com/features/workflow-automation) with a webhook require that the payload variables are flattened with stringified values. Nested variables in the provided payload can be both flattened and also stringified with the `payload-delimiter` option or changed with other [configurations](/tools/slack-github-action/additional-configurations) to match this format expected from Workflow Builder.
### Providing parsed payload information as strings
Provided input values for payload information are sent to the webhook URL after the job is started:
```yaml
- name: Send custom event details to a Slack workflow
uses: slackapi/[email protected]
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
payload: |
status: "${{ job.status }}"
option: "false"
```
### Gathering details of the payload from a saved file
Input values for the payload to be sent can also be provided in a file, either in JSON or YAML format:
```yaml
- name: Send a saved artifact to a Slack workflow
uses: slackapi/[email protected]
with:
payload-file-path: "./artifacts.json"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
```
### Flattening nested payloads
Variables and data provided in the payload might contain nested fields that need to be flattened before being sent with a [webhook trigger](/tools/slack-github-action/sending-data-webhook-slack-workflow) to match the expected input format of [Workflow Builder](https://slack.com/features/workflow-automation).
The `payload-delimiter` option will flatten the input payload using the provided delimiter and will also make values stringified:
```yaml
- name: Flatten the default GitHub payload
uses: slackapi/[email protected]
with:
payload-delimiter: "_"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
```
Reference to the flattening implementation is available for exploration from within the [`flat`](https://www.npmjs.com/package/flat) package.
## Expected outputs
The technique, like all Slack Github Action techniques, [outputs values](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs) that can be used as inputs in following steps of a GitHub workflow.
The following outputs are returned with each of the techniques:
| Output | Type | Description|
|---|---|---|
|`time` | `number` | The Unix [epoch time](https://en.wikipedia.org/wiki/Unix_time) that the step completed.
| `ok` | `boolean` | If the request completed with success.
| `response` | `string` | The [response](/apis/web-api/#responses) from the request as stringified JSON.
## Example workflows
<details>
<summary><strong>Format generated files</strong></summary>
This workflow converts build outputs from earlier GitHub Action steps into a Slack message.
This example uses data from a payload file to [send a message](/tools/deno-slack-sdk/reference/slack-functions/send_message/) to a hardcoded channel.
Payload file being sent
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.data.json
```
GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.gha.yml
```
Slack app manifest
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.manifest.json
```
Slack webhook trigger
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.trigger.json
```
</details>
<details>
<summary><strong>Post release announcements</strong></summary>
This workflow allows you to select a channel to post news about the most recent release to.
This example uses [Slack functions](/tools/deno-slack-sdk/guides/creating-slack-functions/) and inline inputs to do the following:
1. Open a form to select a channel.
2. Send a message to the selected channel.
3. React with a `:tada:` emoji.
GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/announcements.gha.yml
```
Slack app manifest
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/announcements.manifest.json
```
Slack webhook trigger
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/announcements.trigger.json
```
</details>
<details>
<summary><strong>Update a channel topic</strong></summary>
This workflow shows the latest commit status in the header of a channel.
This example uses the default GitHub event [context](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L6) and [payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads) to [update a channel topic](/tools/deno-slack-sdk/reference/slack-functions/update_channel_topic/).
GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/topic.gha.yml
```
Slack app manifest
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/topic.manifest.json
```
Slack webhook trigger
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/topic.trigger.json
```
</details>
@@ -1,13 +0,0 @@
# Example workflow: deploy an app
This workflow deploys a Slack app when changes are pushed to the main branch.
This example uses a service token to authenticate the deploy command.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_4_Slack_CLI_Command/deploy.yml
```
@@ -1,13 +0,0 @@
# Example workflow: manage collaborators
This workflow adds or removes an app collaborator using a manually triggered workflow.
This example combines the Slack API technique ([`users.lookupByEmail`](https://docs.slack.dev/reference/methods/users.lookupByEmail), [`chat.postMessage`](https://docs.slack.dev/reference/methods/chat.postMessage)) with the CLI technique ([`collaborators add`](https://docs.slack.dev/tools/slack-cli/reference/commands/slack_collaborators_add)/[`remove`](https://docs.slack.dev/tools/slack-cli/reference/commands/slack_collaborators_remove)) to look up a user by email, update collaborators, and post a confirmation message.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_4_Slack_CLI_Command/collaborators.yml
```
@@ -1,13 +0,0 @@
# Example workflow: validate a manifest
This workflow validates the app manifest on pull requests to catch configuration issues early.
This example checks the app manifest file in the repository.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_4_Slack_CLI_Command/manifest.yml
```
@@ -1,13 +0,0 @@
# Example workflow: direct message the author
This workflow sends a direct message to the user that pushed the most recent commits.
This example uses the email of the pusher to find the user to send a message to.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_2_Slack_API_Method/author.yml
```
@@ -1,13 +0,0 @@
# Example workflow: invite a usergroup to channel
This workflow creates a channel after a bug is reported and add members of a usergroup.
This example chains multiple Slack API methods together to help fix bugs fast.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_2_Slack_API_Method/invite.yml
```
@@ -1,19 +0,0 @@
# Example workflow: post blocks found in a file
This workflow links to the GitHub Actions job in progress.
This example uses file data when posting to an incoming webhook.
## Files
### Payload file being sent
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/saved.data.json
```
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/saved.gha.yml
```
@@ -1,13 +0,0 @@
# Example workflow: post an inline block message
This workflow formats a response to recent adventures.
This example uses incoming webhooks to post a message with Block Kit.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/blocks.yml
```
@@ -1,13 +0,0 @@
# Example workflow: post an inline text message
This workflow writes a line of text after a push event is received.
This example uses incoming webhooks to post a plain text message.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_3_Slack_Incoming_Webhook/text.yml
```
@@ -1,31 +0,0 @@
# Example workflow: format generated files
This workflow converts build outputs from earlier GitHub Action steps into a Slack message.
This example uses data from a payload file to [send a message](/tools/deno-slack-sdk/reference/slack-functions/send_message/) to a hardcoded channel.
## Files
### Payload file being sent
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.data.json
```
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.gha.yml
```
### Slack app manifest
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.manifest.json
```
### Slack webhook trigger
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/builds.trigger.json
```
@@ -1,31 +0,0 @@
# Example workflow: post release announcements
This workflow allows you to select a channel to post news about the most recent release to.
This example uses [Slack functions](/tools/deno-slack-sdk/guides/creating-slack-functions/) and inline inputs to do the
following:
1. Open a form to select a channel.
2. Send a message to the selected channel.
3. React with a `:tada:` emoji.
## Files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/announcements.gha.yml
```
#### Slack app manifest
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/announcements.manifest.json
```
### Slack webhook trigger
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/announcements.trigger.json
```
@@ -1,78 +0,0 @@
---
sidebar_label: Overview
---
# Sending data via a webhook to start a Slack workflow
:::info[This technique requires [a Slack paid plan](https://slack.com/pricing) to use Workflow Builder.]
:::
This technique sends data to Slack using a webhook to start a workflow created using Slack [Workflow Builder](https://slack.com/features/workflow-automation).
## Setup
Start in Slack to create a Slack workflow:
1. [Create a Slack workflow](https://slack.com/help/articles/360041352714-Build-a-workflow--Create-a-workflow-that-starts-outside-of-Slack) that starts from a webhook.
2. Copy the webhook URL and [add it as a repository secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions#creating-secrets-for-a-repository) called `SLACK_WEBHOOK_URL`.
3. [Add this Action as a step](https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions#jobsjob_idsteps) to your GitHub workflow and provide an input payload to send to the webhook.
4. Configure your Slack workflow to use the payload variables sent from the GitHub Action. You can then update the steps of the Slack workflow to use these values in creative and clever ways.
The webhook URL will resemble something like so:
```txt
https://hooks.slack.com/triggers/T0123456789/3141592653589/c6e6c0d868b3054ca0f4611a5dbadaf
```
## Usage
Update the input payloads sent from this GitHub Action to your Slack workflow using the following options:
### Sending values from the default GitHub event context
In the example below, the default GitHub event [context](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L6) and event [payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads) associated with the job that started the GitHub workflow are sent to the provided webhook URL:
```yaml
- name: Send GitHub Action data to a Slack workflow
uses: slackapi/[email protected]
with:
payload-delimiter: "_"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
```
Accessing variables sent to [Workflow Builder](https://slack.com/features/workflow-automation) with a webhook require that the payload variables are flattened with stringified values. Nested variables in the provided payload can be both flattened and also stringified with the `payload-delimiter` option or changed with other [configurations](/tools/slack-github-action/additional-configurations) to match this format expected from Workflow Builder.
### Providing parsed payload information as strings
Provided input values for payload information are sent to the webhook URL after the job is started:
```yaml
- name: Send custom event details to a Slack workflow
uses: slackapi/[email protected]
with:
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
payload: |
status: "${{ job.status }}"
option: "false"
```
### Gathering details of the payload from a saved file
Input values for the payload to be sent can also be provided in a file, either in JSON or YAML format:
```yaml
- name: Send a saved artifact to a Slack workflow
uses: slackapi/[email protected]
with:
payload-file-path: "./artifacts.json"
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
webhook-type: webhook-trigger
```
## Example workflows
* [**Format generated files**](/tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/format-generated-files): Message outputs from prior steps.
* [**Post release announcements**](/tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/post-release-announcements): Share releases to a channel.
* [**Update a channel topic**](/tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow/update-a-channel-topic): Highlight the current build status.
@@ -1,26 +0,0 @@
# Example workflow: update a channel topic
This workflow shows the latest commit status in the header of a channel.
This example uses the default GitHub event [context](https://github.com/actions/toolkit/blob/main/packages/github/src/context.ts#L6) and [payload](https://docs.github.com/en/webhooks/webhook-events-and-payloads) to [update a channel topic](/tools/deno-slack-sdk/reference/slack-functions/update_channel_topic/).
## Related files
### GitHub Actions workflow
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/topic.gha.yml
```
### Slack app manifest
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/topic.manifest.json
```
### Slack webhook trigger
```js reference
https://github.com/slackapi/slack-github-action/blob/main/example-workflows/Technique_1_Slack_Workflow_Builder/topic.trigger.json
```
@@ -1,56 +0,0 @@
---
sidebar_label: Overview
---
# Sending techniques
This GitHub Action offers four different techniques to interact with Slack:
* [Send data with a webhook to start a workflow in Workflow Builder](/tools/slack-github-action/sending-techniques/sending-data-webhook-slack-workflow).
* [Send data using a Slack API method and a secret token with required scopes](/tools/slack-github-action/sending-techniques/sending-data-slack-api-method/).
* [Send data as a message with a Slack incoming webhook URL](/tools/slack-github-action/sending-techniques/sending-data-slack-incoming-webhook/).
* [Run Slack CLI commands with a service token](/tools/slack-github-action/sending-techniques/running-slack-cli-commands/running-slack-cli-commands).
## Expected outputs
Each technique above [outputs values](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/passing-information-between-jobs) that can be used as inputs in following steps of a GitHub workflow.
The following outputs are returned with each of the techniques:
| Output | Type | Description|
|---|---|---|
|`time` | `number` | The Unix [epoch time](https://en.wikipedia.org/wiki/Unix_time) that the step completed.
| `ok` | `boolean` | If the request completed with success.
| `response` | `string` | The [response](/apis/web-api/#responses) from the request as stringified JSON.
While these outputs are returned with certain Slack API methods:
| Output | Type | Description|
|---|---|---|
|`channel_id` | `string` | The [channel ID](/reference/objects/conversation-object) included in the response.
| `ts`| `string` | The [timestamp](/messaging/retrieving-messages#individual_messages) of the Slack event or message.
| `thread_ts` | `string` | The [timestamp](/messaging/retrieving-messages#individual_messages) of a parent Slack message with [threaded replies](/messaging/retrieving-messages#pulling_threads).
## Example responses
The following snippet shows how multiple steps can be chained together to create a Slack channel before posting a message:
```yaml
- name: Create a new Slack channel for recent changes
id: conversation
uses: slackapi/[email protected]
with:
method: conversations.create
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
name: pull-request-review-${{ github.sha }}
- name: Send the pull request link into the Slack channel
if: ${{ steps.conversation.outputs.ok }}
uses: slackapi/[email protected]
with:
method: chat.postMessage
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel: ${{ steps.conversation.outputs.channel_id }}
text: "A PR was created <!date^${{ steps.conversation.outputs.time }}^{date_num} at {time_secs}|just now>: ${{ github.event.pull_request.html_url }}"
```
+9
View File
@@ -2,6 +2,15 @@
The Slack GitHub Action is for sending data to Slack and running commands.
The Slack GitHub Action offers four different techniques for sending data to and interacting with Slack:
* [Send data with a webhook to start a workflow in Workflow Builder](/tools/slack-github-action/sending-data-webhook-slack-workflow).
* [Send data using a Slack API method and a secret token with required scopes](/tools/slack-github-action/sending-data-slack-api-method/).
* [Send data as a message with a Slack incoming webhook URL](/tools/slack-github-action/sending-data-slack-incoming-webhook/).
* [Run Slack CLI commands](/tools/slack-github-action/running-slack-cli-commands).
---
## Versioning
We recommend using the latest version of this GitHub Action for the most recent updates and fixes.