| sidebar_label | Overview |
|---|
This GitHub Action offers four different techniques to interact with Slack:
- Send data with a webhook to start a workflow in Workflow Builder.
- Send data using a Slack API method and a secret token with required scopes.
- Send data as a message with a Slack incoming webhook URL.
- Run Slack CLI commands with a service token.
Each technique above outputs values 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 that the step completed. |
ok |
boolean |
If the request completed with success. |
response |
string |
The response 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 included in the response. |
ts |
string |
The timestamp of the Slack event or message. |
thread_ts |
string |
The timestamp of a parent Slack message with threaded replies. |
The following snippet shows how multiple steps can be chained together to create a Slack channel before posting a message:
- name: Create a new Slack channel for recent changes
id: conversation
uses: slackapi/slack-github-action@v3.0.1
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/slack-github-action@v3.0.1
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 }}"