Skip to content

Commit 66e2922

Browse files
committed
Addressing PR comments.
1 parent 04ab2f1 commit 66e2922

File tree

4 files changed

+67
-60
lines changed

4 files changed

+67
-60
lines changed

.github/resources/.actions/cli-runner/action.yml

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
name: Slack CLI Installation and Command Runner
2-
description: Download and cache the Slack CLI and run the input command
1+
name: "Slack: Run a CLI command"
2+
description: "Install the Slack CLI to run a command"
33

44
inputs:
55
command:
6-
description: "Slack CLI command to run"
6+
description: "Slack CLI command to run. Should not include the 'slack' prefix."
77
type: string
88
default: ""
99
required: true
@@ -12,10 +12,10 @@ inputs:
1212
type: boolean
1313
default: false
1414
required: false
15-
cli_version:
15+
cli-version:
1616
description: "CLI Version"
1717
type: string
18-
default: "latest"
18+
default: "3.6.1"
1919
required: false
2020
app_id:
2121
description: "App ID"
@@ -24,29 +24,29 @@ inputs:
2424
required: false
2525

2626
outputs:
27-
success:
28-
description: "Whether the command ran successfully"
29-
value: ${{ steps.run-slack-cli-command.outputs.success }}
27+
ok:
28+
description: "If the command completed without an error."
29+
value: ${{ steps.run-slack-cli-command.outputs.ok || steps.run-slack-cli-command-windows.outputs.ok }}
3030
exit_code:
3131
description: "Exit code"
32-
value: ${{ steps.run-slack-cli-command.outputs.exit_code }}
32+
value: ${{ steps.run-slack-cli-command.outputs.exit_code || steps.run-slack-cli-command-windows.outputs.exit_code }}
3333
command_executed:
3434
description: "Command ran"
35-
value: ${{ steps.run-slack-cli-command.outputs.command_executed }}
36-
stdout:
35+
value: ${{ steps.run-slack-cli-command.outputs.command_executed || steps.run-slack-cli-command-windows.outputs.command_executed }}
36+
output:
3737
description: "Command output"
38-
value: ${{ steps.run-slack-cli-command.outputs.stdout }}
38+
value: ${{ steps.run-slack-cli-command.outputs.output || steps.run-slack-cli-command-windows.outputs.output }}
3939

4040
runs:
4141
using: composite
4242
steps:
4343
- name: Cache Slack CLI
4444
id: cache-cli
45-
uses: actions/cache@v4
45+
uses: actions/cache@0400d5f644dc74513175e3cd8d07132dd4860809 # v4.2.4
4646
with:
4747
path: |
4848
${{ runner.os == 'Windows' && format('{0}/AppData/Local/slack-cli', env.USERPROFILE) || '~/.slack/bin' }}
49-
key: slack-cli-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cli_version }}
49+
key: slack-cli-${{ runner.os }}-${{ runner.arch }}-${{ inputs.cli-version }}
5050

5151
- name: Add Slack CLI to PATH (Linux/macOS)
5252
if: runner.os != 'Windows'
@@ -64,7 +64,7 @@ runs:
6464
(steps.cache-cli.outputs.cache-hit != 'true')
6565
shell: bash
6666
run: |
67-
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v ${{ inputs.cli_version }} --skip-update
67+
curl -fsSL https://downloads.slack-edge.com/slack-cli/install.sh | bash -s -- -v ${{ inputs.cli_version }}
6868
6969
- name: Install Slack CLI (Windows)
7070
if:
@@ -94,11 +94,11 @@ runs:
9494
echo "Command output: $output"
9595
echo "Exit code: $exit_code"
9696
97-
echo "success=$([ $exit_code -eq 0 ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
97+
echo "ok=$([ $exit_code -eq 0 ] && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
9898
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT
9999
echo "command_executed=slack ${{ inputs.command }} --skip-update" >> $GITHUB_OUTPUT
100100

101-
echo "stdout<<EOF" >> $GITHUB_OUTPUT
101+
echo "output<<EOF" >> $GITHUB_OUTPUT
102102
echo "$output" >> $GITHUB_OUTPUT
103103
echo "EOF" >> $GITHUB_OUTPUT
104104

@@ -120,11 +120,11 @@ runs:
120120
Write-Host "Command output: $output"
121121
Write-Host "Exit code: $exit_code"
122122
123-
"success=$($exit_code -eq 0)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
123+
"ok=$($exit_code -eq 0)" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
124124
"exit_code=$exit_code" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
125125
"command_executed=$cmd" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
126126
127-
"stdout<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
127+
"output<<EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
128128
$output | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
129129
"EOF" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
130130
Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Slack CLI Command Runner Tests
1+
name: Slack CLI Runner Tests
22

33
on:
44
pull_request:
@@ -7,36 +7,37 @@ jobs:
77
test-all:
88
runs-on: ubuntu-latest
99
steps:
10-
- uses: actions/checkout@v4
10+
- name: Checkout the current code
11+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1112

1213
- name: Run slack version
1314
id: version
1415
uses: ./.github/resources/.actions/cli-runner
1516
with:
1617
command: "version"
17-
cli_version: "latest"
18+
cli-version: "3.6.1"
1819
env:
1920
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
2021

2122
- name: Debug outputs
2223
run: |
23-
echo "stdout: '${{ steps.version.outputs.stdout }}'"
24-
echo "success: '${{ steps.version.outputs.success }}'"
24+
echo "output: '${{ steps.version.outputs.output }}'"
25+
echo "ok: '${{ steps.version.outputs.ok }}'"
2526
echo "command executed: '${{ steps.version.outputs.command_executed }}'"
2627
2728
- name: Verify CLI version
28-
if: steps.version.outputs.success != 'true'
29+
if: steps.version.outputs.ok != 'true'
2930
run: |
3031
echo "CLI version command failure"
31-
echo "stdout: ${{ steps.version.outputs.stdout }}"
32+
echo "output: ${{ steps.version.outputs.output }}"
3233
exit 1
3334
3435
- name: Empty command
3536
id: empty-command
3637
uses: ./.github/resources/.actions/cli-runner
3738
with:
3839
command: ""
39-
cli_version: "latest"
40+
cli-version: "3.6.1"
4041
env:
4142
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
4243

@@ -45,7 +46,7 @@ jobs:
4546
uses: ./.github/resources/.actions/cli-runner
4647
with:
4748
command: " version"
48-
cli_version: "latest"
49+
cli-version: "3.6.1"
4950
env:
5051
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
5152

@@ -54,58 +55,58 @@ jobs:
5455
uses: ./.github/resources/.actions/cli-runner
5556
with:
5657
command: 'doctor --help --experiment string'
57-
cli_version: "latest"
58+
cli-version: "3.6.1"
5859
env:
5960
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
6061

6162
- name: Ensure empty command works
62-
if: steps.empty-command.outputs.success != 'true'
63+
if: steps.empty-command.outputs.ok != 'true'
6364
run: |
6465
echo "Empty command failure"
65-
echo "success: '${{ steps.empty-command.outputs.success }}'"
66-
echo "stdout: '${{ steps.empty-command.outputs.stdout }}'"
66+
echo "ok: '${{ steps.empty-command.outputs.ok }}'"
67+
echo "output: '${{ steps.empty-command.outputs.output }}'"
6768
exit 1
6869
6970
- name: Ensure command with whitespace
70-
if: steps.command-with-whitespace.outputs.success != 'true'
71+
if: steps.command-with-whitespace.outputs.ok != 'true'
7172
run: |
7273
echo "Command with whitespace failure"
73-
echo "success: '${{ steps.command-with-whitespace.outputs.success }}'"
74-
echo "stdout: '${{ steps.command-with-whitespace.outputs.stdout }}'"
74+
echo "ok: '${{ steps.command-with-whitespace.outputs.ok }}'"
75+
echo "output: '${{ steps.command-with-whitespace.outputs.output }}'"
7576
exit 1
7677
7778
- name: Ensure long command works
78-
if: steps.long-command.outputs.success != 'true'
79+
if: steps.long-command.outputs.ok != 'true'
7980
run: |
8081
echo "Long command failure"
81-
echo "success: '${{ steps.long-command.outputs.success }}'"
82-
echo "stdout: '${{ steps.long-command.outputs.stdout }}'"
82+
echo "ok: '${{ steps.long-command.outputs.ok }}'"
83+
echo "output: '${{ steps.long-command.outputs.output }}'"
8384
exit 1
8485
8586
- name: Run with verbose
8687
id: with-verbose
8788
uses: ./.github/resources/.actions/cli-runner
8889
with:
8990
command: "help"
90-
cli_version: "latest"
91+
cli-version: "3.6.1"
9192
verbose: "true"
9293
env:
9394
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
9495

9596
- name: Ensure verbose flag worked
96-
if: steps.with-verbose.outputs.success != 'true'
97+
if: steps.with-verbose.outputs.ok != 'true'
9798
run: |
9899
echo "Verbose flag failure"
99-
echo "success: '${{ steps.with-verbose.outputs.success }}'"
100-
echo "stdout: '${{ steps.with-verbose.outputs.stdout }}'"
100+
echo "ok: '${{ steps.with-verbose.outputs.ok }}'"
101+
echo "output: '${{ steps.with-verbose.outputs.output }}'"
101102
exit 1
102103
103104
- name: First run (install if missing)
104105
id: no-cache
105106
uses: ./.github/resources/.actions/cli-runner
106107
with:
107108
command: "version"
108-
cli_version: "latest"
109+
cli-version: "3.6.1"
109110
env:
110111
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
111112

@@ -114,13 +115,13 @@ jobs:
114115
uses: ./.github/resources/.actions/cli-runner
115116
with:
116117
command: "version"
117-
cli_version: "latest"
118+
cli-version: "3.6.1"
118119
env:
119120
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
120121
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
121122

122123
- name: Ensure cache worked
123-
if: github.run_attempt > 1 && steps.cache-hit.outputs.success != 'true'
124+
if: github.run_attempt > 1 && steps.cache-hit.outputs.ok != 'true'
124125
run: |
125126
echo "cache failure"
126127
exit 1
@@ -131,30 +132,30 @@ jobs:
131132
uses: ./.github/resources/.actions/cli-runner
132133
with:
133134
command: "invalid-command"
134-
cli_version: "latest"
135+
cli-version: "3.6.1"
135136
env:
136137
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
137138

138139
- name: Expect failure
139-
if: steps.invalid-command.outputs.success == 'true'
140+
if: steps.invalid-command.outputs.ok == 'true'
140141
run: |
141142
echo "Expected failure with invalid command"
142-
echo "stdout: '${{ steps.invalid-command.outputs.stdout }}'"
143-
echo "success: '${{ steps.invalid-command.outputs.success }}'"
143+
echo "output: '${{ steps.invalid-command.outputs.output }}'"
144+
echo "ok: '${{ steps.invalid-command.outputs.ok }}'"
144145
exit 1
145146
146147
- name: Test specific version
147148
id: specific-version
148149
uses: ./.github/resources/.actions/cli-runner
149150
with:
150151
command: "version"
151-
cli_version: "3.5.0"
152+
cli-version: "3.5.0"
152153
env:
153154
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}
154155

155156
- name: Ensure specific version
156-
if: ${{ !contains(steps.specific-version.outputs.stdout, '3.5.0') }}
157+
if: ${{ !contains(steps.specific-version.outputs.output, '3.5.0') }}
157158
run: |
158159
echo "Specific version failure"
159-
echo "stdout: '${{ steps.specific-version.outputs.stdout }}'"
160+
echo "output: '${{ steps.specific-version.outputs.output }}'"
160161
exit 1

.github/workflows/cli-runner.yml

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_call:
55
inputs:
66
command:
7-
description: 'Slack CLI command to run'
7+
description: 'Slack CLI command to run. Should not include the 'slack' prefix.'
88
type: string
99
default: ""
1010
required: true
@@ -13,10 +13,10 @@ on:
1313
type: boolean
1414
default: false
1515
required: false
16-
cli_version:
16+
cli-version:
1717
description: 'CLI version'
1818
type: string
19-
default: "latest"
19+
default: "3.6.1"
2020
required: false
2121
app_id:
2222
description: "App ID"
@@ -33,21 +33,22 @@ jobs:
3333
contents: read
3434
runs-on: ubuntu-latest
3535
outputs:
36-
success: ${{ steps.run-slack-cli-command.outputs.success }}
36+
ok: ${{ steps.run-slack-cli-command.outputs.ok }}
3737
command_executed: ${{ steps.run-slack-cli-command.outputs.command_executed }}
38-
stdout: ${{ steps.run-slack-cli-command.outputs.stdout }}
38+
output: ${{ steps.run-slack-cli-command.outputs.output }}
3939
timeout-minutes: 5
4040

4141
steps:
42-
- uses: actions/checkout@v4
42+
- name: Checkout the current code
43+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
4344

4445
- name: Install Slack CLI and Run Command
4546
id: run-slack-cli-command
4647
uses: ./.github/resources/.actions/cli-runner
4748
with:
4849
command: ${{ github.event.inputs.command }}
4950
verbose: ${{ github.event.inputs.verbose == 'true' || github.run_attempt > 1 }}
50-
cli_version: ${{ github.event.inputs.cli_version }}
51+
cli-version: ${{ github.event.inputs.cli-version }}
5152
app_id: ${{ github.event.inputs.app_id }}
5253
env:
5354
SLACK_SERVICE_TOKEN: ${{ secrets.SLACK_SERVICE_TOKEN }}

docs/sending-techniques/sending-data-cli-runner/sending-data-cli-runner.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ Setting up a CI/CD pipeline [requires](https://docs.slack.dev/tools/slack-cli/gu
1010

1111
## Setup
1212

13-
1. Add your service token as a [repository secret](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-a-repository) called SLACK_SERVICE_TOKEN.
13+
1. Add your service token as a [repository secret](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-a-repository). Settings > Security > Secrets and variables > Actions and click the "New repository secret" button.
14+
15+
Name: SLACK_SERVICE_TOKEN
16+
17+
Secret: the xoxp- service token
18+
1419
2. Add this workflow to your repository. GitHub Actions workflow files must be stored in the .github/workflows directory
1520

1621
```yaml

0 commit comments

Comments
 (0)