Skip to content

Latest commit

 

History

History
56 lines (44 loc) · 2.72 KB

File metadata and controls

56 lines (44 loc) · 2.72 KB
sidebar_label Overview

Sending techniques

This GitHub Action offers four different techniques to interact with Slack:

Expected outputs

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.

Example responses

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 }}"