11name : " Slack: Send to Slack"
22author : " slackapi"
3- description : " Send data to Slack to start a Slack workflow in Workflow Builder, call a Slack API method, post a message into a channel, or run a Slack CLI command "
3+ description : " Send data to Slack to start a Slack workflow in Workflow Builder, call a Slack API method, or post a message into a channel"
44inputs :
55 api :
66 description : " A custom API URL to send Slack API method requests to."
77 required : false
8- command :
9- description : " A Slack CLI command to run without the 'slack' prefix."
10- required : false
118 errors :
129 default : " false"
1310 description : " If the step exits with an error on errors or continues."
@@ -37,9 +34,6 @@ inputs:
3734 token :
3835 description : " The authentication value used with the Slack API."
3936 required : false
40- version :
41- description : " The version of the Slack CLI to install."
42- required : false
4337 webhook :
4438 description : " A location for posting request payloads."
4539 required : false
@@ -49,141 +43,16 @@ inputs:
4943outputs :
5044 ok :
5145 description : " If the request completed without returning errors."
52- value : ${{ steps.slack-send.outputs.ok || steps.slack-cli.outputs.ok }}
5346 response :
5447 description : " A JSON stringified version of the Slack API response."
55- value : ${{ steps.slack-send.outputs.response || steps.slack-cli.outputs.response }}
5648 time :
5749 description : " The Unix epoch time that the step completed."
58- value : ${{ steps.slack-send.outputs.time || steps.slack-cli.outputs.time }}
5950 channel_id :
6051 description : " The channel ID returned with some of the Slack API methods."
61- value : ${{ steps.slack-send.outputs.channel_id }}
6252 thread_ts :
6353 description : " The timestamp of a parent Slack message with threaded replies."
64- value : ${{ steps.slack-send.outputs.thread_ts }}
6554 ts :
6655 description : " The timestamp of a Slack message or event in the response."
67- value : ${{ steps.slack-send.outputs.ts }}
6856runs :
69- using : composite
70- steps :
71- - name : Validate inputs
72- if : inputs.command != '' && (inputs.method != '' || inputs.webhook != '')
73- shell : bash
74- run : |
75- echo "::error::The 'command' input cannot be combined with 'method' or 'webhook' inputs."
76- exit 1
77-
78- - name : Send data to Slack
79- id : slack-send
80- if : inputs.command == ''
81- shell : bash
82- run : node "${{ github.action_path }}/dist/index.js"
83- env :
84- INPUT_API : ${{ inputs.api }}
85- INPUT_ERRORS : ${{ inputs.errors }}
86- INPUT_METHOD : ${{ inputs.method }}
87- INPUT_PAYLOAD : ${{ inputs.payload }}
88- INPUT_PAYLOAD-DELIMITER : ${{ inputs.payload-delimiter }}
89- INPUT_PAYLOAD-FILE-PATH : ${{ inputs.payload-file-path }}
90- INPUT_PAYLOAD-TEMPLATED : ${{ inputs.payload-templated }}
91- INPUT_PROXY : ${{ inputs.proxy }}
92- INPUT_RETRIES : ${{ inputs.retries }}
93- INPUT_TOKEN : ${{ inputs.token }}
94- INPUT_WEBHOOK : ${{ inputs.webhook }}
95- INPUT_WEBHOOK-TYPE : ${{ inputs.webhook-type }}
96-
97- - name : Check if Slack CLI already exists
98- id : slack-cli-check
99- if : inputs.command != ''
100- shell : bash
101- run : |
102- if command -v slack &> /dev/null; then
103- echo "cli-exists=true" >> "$GITHUB_OUTPUT"
104- else
105- echo "cli-exists=false" >> "$GITHUB_OUTPUT"
106- fi
107-
108- - name : Cache Slack CLI
109- if : inputs.command != '' && steps.slack-cli-check.outputs.cli-exists != 'true'
110- id : cache-cli
111- uses : actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
112- with :
113- path : |
114- ${{ runner.os == 'Windows' && format('{0}\AppData\Local\slack-cli', env.USERPROFILE) || format('{0}/.slack/bin', env.HOME) }}
115- key : slack-cli-${{ runner.os }}-${{ runner.arch }}-${{ inputs.version }}
116-
117- - name : Add Slack CLI to PATH (Linux/macOS)
118- if : inputs.command != '' && steps.slack-cli-check.outputs.cli-exists != 'true' && runner.os != 'Windows'
119- shell : bash
120- run : echo "$HOME/.slack/bin" >> "$GITHUB_PATH"
121-
122- - name : Add Slack CLI to PATH (Windows)
123- if : inputs.command != '' && steps.slack-cli-check.outputs.cli-exists != 'true' && runner.os == 'Windows'
124- shell : pwsh
125- run : Add-Content -Path $env:GITHUB_PATH -Value "$env:USERPROFILE\.slack\bin"
126-
127- - name : Install Slack CLI (Linux/macOS)
128- if : >-
129- inputs.command != '' &&
130- steps.slack-cli-check.outputs.cli-exists != 'true' &&
131- steps.cache-cli.outputs.cache-hit != 'true' &&
132- runner.os != 'Windows'
133- shell : bash
134- run : |
135- if [ -n "$SLACK_CLI_VERSION" ]; then
136- curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v "$SLACK_CLI_VERSION"
137- else
138- curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s
139- fi
140- env :
141- SLACK_CLI_VERSION : ${{ inputs.version }}
142-
143- - name : Install Slack CLI (Windows)
144- if : >-
145- inputs.command != '' &&
146- steps.slack-cli-check.outputs.cli-exists != 'true' &&
147- steps.cache-cli.outputs.cache-hit != 'true' &&
148- runner.os == 'Windows'
149- shell : pwsh
150- run : |
151- if ($env:SLACK_CLI_VERSION) {
152- $installer = Join-Path $env:TEMP "install-slack-cli.ps1"
153- Invoke-WebRequest -Uri "https://downloads.slack-edge.com/slack-cli/install-windows-dev.ps1" -OutFile $installer
154- & $installer -v $env:SLACK_CLI_VERSION
155- } else {
156- irm https://downloads.slack-edge.com/slack-cli/install-windows-dev.ps1 | iex
157- }
158- env :
159- SLACK_CLI_VERSION : ${{ inputs.version }}
160-
161- - name : Run Slack CLI command
162- id : slack-cli
163- if : inputs.command != ''
164- shell : bash
165- env :
166- SLACK_COMMAND : ${{ inputs.command }}
167- SLACK_TOKEN : ${{ inputs.token }}
168- run : |
169- args="$SLACK_COMMAND --skip-update"
170- if [ -n "$SLACK_TOKEN" ]; then
171- args="$args --token $SLACK_TOKEN"
172- fi
173-
174- set +e
175- output=$(slack $args 2>&1)
176- exit_code=$?
177- set -e
178-
179- echo "ok=$([ $exit_code -eq 0 ] && echo 'true' || echo 'false')" >> "$GITHUB_OUTPUT"
180- echo "time=$(date +%s)" >> "$GITHUB_OUTPUT"
181-
182- echo "response<<SLACKCLIEOF" >> "$GITHUB_OUTPUT"
183- echo "$output" >> "$GITHUB_OUTPUT"
184- echo "SLACKCLIEOF" >> "$GITHUB_OUTPUT"
185-
186- if [ $exit_code -ne 0 ]; then
187- echo "::error::Slack CLI command failed with exit code $exit_code"
188- exit $exit_code
189- fi
57+ using : " node20"
58+ main : " dist/index.js"
0 commit comments