-
Notifications
You must be signed in to change notification settings - Fork 182
feat: support slack cli commands with composite action inputs #560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
ae50e2e
165d9f6
2d8c996
077f882
35b8102
5d5197b
613ab73
47ed37c
4e7d5d3
f50140b
b48e5cf
32371dd
059f8f3
eaed8db
65f25ff
4b307de
2d3baa1
c6baa4b
8607d1d
d343286
e2bce82
fc6915d
6f7dc50
ddae541
4a0cf78
d8247ad
3698dd9
8a37599
86c95e5
809cf5c
c73fa17
069243d
5d9cb89
ae9124d
4aab456
2d9b061
03b6946
638743f
671d51b
1003081
22fc69b
cba9656
4500857
e29bb10
398c562
16992d6
a76349b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,7 @@ | ||
| { | ||
| "experiments": ["bolt"], | ||
| "manifest": { | ||
| "source": "local" | ||
| }, | ||
| "project_id": "c4805b41-d1ce-4ea0-b297-ed2f8c64c267" | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,7 @@ experiments with the [Slack CLI][cli]. | |
|
|
||
| ## Overview | ||
|
|
||
| This app showcases all three techniques of sending data into Slack and follows | ||
| This app showcases all four techniques of interacting with Slack and follows | ||
| patterns found in the integration tests. | ||
|
|
||
| - **Technique 1** Slack Workflow Builder: Use a Slack webhook trigger to start a | ||
|
|
@@ -15,13 +15,18 @@ patterns found in the integration tests. | |
| data provided through the GitHub workflow. | ||
| - **Technique 3** Incoming webhook: Post a message to a Slack channel using an | ||
| incoming webhook. | ||
| - **Technique 4** Slack CLI Command: Install and run Slack CLI commands such as | ||
| `deploy` or `manifest` using a service token. | ||
|
|
||
| Configurations for the Slack app and workflow, and the GitHub Actions workflow | ||
| are found in the following files: | ||
|
|
||
| - Slack app setup: [`.github/resources/.slack/manifest.json`][slacktion] | ||
| - GitHub Actions steps: [`.github/workflows/develop.yml`][develop] | ||
|
|
||
| > **Note:** During CLI integration tests, `.github/resources/.slack` is moved to | ||
| > `.slack` at the project root so the Slack CLI can discover the app manifest. | ||
|
Comment on lines
+27
to
+28
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔭 thought: This might be a limitation of the CLI at the moment. I think patterns exist elsewhere toward this, but I'm curious if an option in this action makes more sense... |
||
|
|
||
| Either the techniques or app setup and workflow steps can be adjusted during | ||
| testing and development. For experimenting with new changes, we recommend using | ||
| the [steps for development](#experimenting-for-development) while the | ||
|
|
@@ -76,6 +81,8 @@ tested. Required values include: | |
| https://hooks.slack.com/services/T0123456789/B0123456789/abcdefghijklmnopqrstuvwxyz | ||
| - `SLACK_WEBHOOK_TRIGGER`: | ||
| https://hooks.slack.com/triggers/T0123456789/00000000000/abcdefghijklmnopqrstuvwxyz | ||
| - `SLACK_SERVICE_TOKEN`: xoxp-service-token-example (secret — for CLI commands) | ||
| - `SLACK_APP_ID`: A0123456789 (variable — used with `--app` flag in CLI deploy) | ||
|
|
||
| ### Experimenting for development | ||
|
|
||
|
|
@@ -98,6 +105,7 @@ export SLACK_BOT_TOKEN=xoxb-01010101-example | |
| export SLACK_CHANNEL_ID=C0123456789 | ||
| export SLACK_INCOMING_WEBHOOK=https://hooks.slack.com/services/T0123456789/B0123456789/abcdefghijklmnopqrstuvwxyz | ||
| export SLACK_WEBHOOK_TRIGGER=https://hooks.slack.com/triggers/T0123456789/00000000000/abcdefghijklmnopqrstuvwxyz | ||
| export SLACK_SERVICE_TOKEN=xoxp-service-token-example | ||
| ``` | ||
|
|
||
| Environment variables and credentials should be set in the created `.env` file | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ on: | |
|
|
||
| jobs: | ||
| integration: | ||
| name: Run integration tests | ||
| name: Run API tests | ||
| runs-on: ubuntu-latest | ||
| environment: staging | ||
| permissions: | ||
|
|
@@ -68,7 +68,7 @@ jobs: | |
| env: | ||
| INPUT_REF: ${{ inputs.ref }} | ||
|
|
||
| - name: "integration(wfb): send a payload to workflow builder via webhook trigger" | ||
| - name: "test(wfb): send a payload to workflow builder via webhook trigger" | ||
| id: wfb | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -82,12 +82,12 @@ jobs: | |
| repo_name: ${{ github.event.repository.full_name }} | ||
| status: ${{ job.status }} | ||
|
|
||
| - name: "integration(wfb): confirm a payload was sent" | ||
| - name: "test(wfb): confirm a payload was sent" | ||
| run: test -n "$WFB_OUTPUT_TIME" | ||
| env: | ||
| WFB_OUTPUT_TIME: ${{ steps.wfb.outputs.time }} | ||
|
|
||
| - name: "integration(botToken): post a message to channel" | ||
| - name: "test(api): post a message to channel" | ||
| id: message | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -98,12 +98,12 @@ jobs: | |
| channel: ${{ secrets.SLACK_CHANNEL_ID }} | ||
| text: ":checkered_flag: Action happens at <https://github.com/${{ github.repository }}>" | ||
|
|
||
| - name: "integration(method): confirm a message was posted" | ||
| - name: "test(api): confirm a message was posted" | ||
| run: test -n "$MESSAGE_OUTPUT_TS" | ||
| env: | ||
| MESSAGE_OUTPUT_TS: ${{ steps.message.outputs.ts }} | ||
|
|
||
| - name: "integration(method): post a message with blocks" | ||
| - name: "test(api): post a message with blocks" | ||
| id: blocks | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -120,12 +120,12 @@ jobs: | |
| short: true | ||
| value: "Processing" | ||
|
|
||
| - name: "integration(method): confirm the blocks were posted" | ||
| - name: "test(api): confirm the blocks were posted" | ||
| run: test -n "$BLOCKS_OUTPUT_TS" | ||
| env: | ||
| BLOCKS_OUTPUT_TS: ${{ steps.blocks.outputs.ts }} | ||
|
|
||
| - name: "integration(method): post a threaded message" | ||
| - name: "test(api): post a threaded message" | ||
| id: timer | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -137,15 +137,15 @@ jobs: | |
| text: "Started at `${{ steps.blocks.outputs.time }}`" | ||
| thread_ts: "${{ steps.blocks.outputs.ts }}" | ||
|
|
||
| - name: "integration(incoming): confirm the thread started" | ||
| - name: "test(api): confirm the thread started" | ||
| run: test -n "$TIMER_OUTPUT_TIME" | ||
| env: | ||
| TIMER_OUTPUT_TIME: ${{ steps.timer.outputs.time }} | ||
|
|
||
| - name: "integration(method): wait to mock event processing" | ||
| - name: "test(api): wait to mock event processing" | ||
| run: sleep 3 | ||
|
|
||
| - name: "integration(method): update the original message" | ||
| - name: "test(api): update the original message" | ||
| id: finished | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -163,7 +163,7 @@ jobs: | |
| short: true | ||
| value: "Completed" | ||
|
|
||
| - name: "integration(method): post another threaded message" | ||
| - name: "test(api): post another threaded message" | ||
| id: done | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -175,7 +175,7 @@ jobs: | |
| text: "Finished at `${{ steps.finished.outputs.time }}`" | ||
| thread_ts: "${{ steps.timer.outputs.thread_ts }}" | ||
|
|
||
| - name: "integration(method): post a file into a channel" | ||
| - name: "test(api): post a file into a channel" | ||
| id: file | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -188,7 +188,7 @@ jobs: | |
| file: .github/workflows/integration.yml | ||
| filename: integration.yml | ||
|
|
||
| - name: "integration(method): react to the completed update message" | ||
| - name: "test(api): react to the completed update message" | ||
| uses: ./ | ||
| with: | ||
| errors: true | ||
|
|
@@ -199,38 +199,38 @@ jobs: | |
| timestamp: ${{ steps.blocks.outputs.ts }} | ||
| name: "tada" | ||
|
|
||
| - name: "integration(method): confirm the thread ended" | ||
| - name: "test(api): confirm the thread ended" | ||
| run: test -n "$DONE_OUTPUT_TIME" | ||
| env: | ||
| DONE_OUTPUT_TIME: ${{ steps.done.outputs.time }} | ||
|
|
||
| - name: "integration(incoming): post a message via incoming webhook" | ||
| - name: "test(incoming): post a message via incoming webhook" | ||
| id: incoming | ||
| uses: ./ | ||
| with: | ||
| errors: true | ||
| webhook: ${{ secrets.SLACK_INCOMING_WEBHOOK }} | ||
| webhook-type: incoming-webhook | ||
| payload: | | ||
| text: "Incoming webhook test for slack send" | ||
| text: "Incoming webhook test for the Slack GitHub Action" | ||
| blocks: | ||
| - type: section | ||
| text: | ||
| type: plain_text | ||
| text: ":link: A message was received via incoming webhook" | ||
| emoji: true | ||
|
|
||
| - name: "integration(incoming): confirm a webhook was posted" | ||
| - name: "test(incoming): confirm a webhook was posted" | ||
| run: test -n "$INCOMING_WEBHOOK_OUTPUT_TIME" | ||
| env: | ||
| INCOMING_WEBHOOK_OUTPUT_TIME: ${{ steps.incoming.outputs.time }} | ||
|
|
||
| - name: "integration(incoming): reveal contents of the github payload" | ||
| - name: "test(incoming): reveal contents of the github payload" | ||
| run: echo "$JSON" | ||
| env: | ||
| JSON: ${{ toJSON(github) }} | ||
|
|
||
| - name: "integration(incoming): post a message via payload file" | ||
| - name: "test(incoming): post a message via payload file" | ||
| id: payload_file | ||
| uses: ./ | ||
| with: | ||
|
|
@@ -243,15 +243,80 @@ jobs: | |
| JOB_STATUS: ${{ job.status }} | ||
| ATTACHMENT_COLOR: ${{ (job.status == 'success' && 'good') || (job.status == 'failure' && 'danger') || 'warning' }} | ||
|
|
||
| - name: "integration(incoming): confirm a payload file was posted" | ||
| - name: "test(incoming): confirm a payload file was posted" | ||
| run: test -n "$PAYLOAD_FILE_OUTPUT_TIME" | ||
| env: | ||
| PAYLOAD_FILE_OUTPUT_TIME: ${{ steps.payload_file.outputs.time }} | ||
|
|
||
| - name: "chore(health): check up on recent changes to the health score" | ||
| uses: slackapi/slack-health-score@d58a419f15cdaff97e9aa7f09f95772830ab66f7 # v0.1.1 | ||
| cli: | ||
| name: Run CLI tests | ||
| runs-on: ${{ matrix.os }} | ||
| environment: staging | ||
| strategy: | ||
| fail-fast: false | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
| - macos-latest | ||
| - windows-latest | ||
|
Comment on lines
+259
to
+261
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice 💯 |
||
| permissions: | ||
| contents: read | ||
| steps: | ||
| - name: "build: checkout the latest changes" | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| persist-credentials: false | ||
| ref: ${{ inputs.ref || github.event.pull_request.head.sha || github.sha }} | ||
|
|
||
| - name: "test(cli): run a slack cli version check" | ||
| id: version | ||
| uses: ./cli | ||
| with: | ||
| command: "version" | ||
|
|
||
| - name: "test(cli): confirm the version check outputs" | ||
| shell: bash | ||
| run: | | ||
| set -ex | ||
| [ "$CLI_OK" = "true" ] | ||
| echo "$CLI_TIME" | grep -qE '^[0-9]+$' | ||
| [ -n "$CLI_RESPONSE" ] | ||
| env: | ||
| CLI_OK: ${{ steps.version.outputs.ok }} | ||
| CLI_RESPONSE: ${{ steps.version.outputs.response }} | ||
| CLI_TIME: ${{ steps.version.outputs.time }} | ||
|
|
||
| - name: "test(cli): run an unknown command" | ||
| id: unknown | ||
| continue-on-error: true | ||
| uses: ./cli | ||
| with: | ||
| command: "off" | ||
|
|
||
| - name: "test(cli): confirm the unknown command outputs" | ||
| shell: bash | ||
| run: | | ||
| set -ex | ||
| [ "$CLI_OK" = "false" ] | ||
| echo "$CLI_TIME" | grep -qE '^[0-9]+$' | ||
| [ -n "$CLI_RESPONSE" ] | ||
| env: | ||
| CLI_OK: ${{ steps.unknown.outputs.ok }} | ||
| CLI_RESPONSE: ${{ steps.unknown.outputs.response }} | ||
| CLI_TIME: ${{ steps.unknown.outputs.time }} | ||
|
|
||
| - name: "chore: configure the actioneering application" | ||
| shell: bash | ||
| run: mv .github/resources/.slack .slack | ||
|
|
||
| - name: "test(cli): validate the app manifest" | ||
| uses: ./cli | ||
| with: | ||
| command: "manifest" | ||
| token: ${{ secrets.SLACK_SERVICE_TOKEN }} | ||
|
|
||
| - name: "test(cli): deploy the app" | ||
| uses: ./cli | ||
| with: | ||
| codecov_token: ${{ secrets.CODECOV_API_TOKEN }} | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| extension: js | ||
| include: src | ||
|
Comment on lines
-254
to
-257
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔏 note: This is also removed in #559 but status checks are being reported as error for forked branches at this time. |
||
| command: "deploy --app ${{ vars.SLACK_APP_ID }} --hide-triggers --force" | ||
| token: ${{ secrets.SLACK_SERVICE_TOKEN }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,9 @@ jobs: | |
| uses: teunmooij/github-versioned-release@3edf649c6e5e5e976d43f2584b15bdc8b4c8f0df # v1.2.1 | ||
| with: | ||
| template: javascript-action | ||
| include: | | ||
| dist/**/* | ||
| cli/**/* | ||
|
Comment on lines
+41
to
+43
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📠 note: An example build shows both directories and adjacent files exist and work as expected! 📦 https://github.com/zimeg/slack-github-action/tree/v2.2.0-rc.1 |
||
| env: | ||
| GITHUB_TOKEN: ${{ github.token }} | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
question: Is
project_idreplaced when the GitHub Action runs? Or, will all GitHub Actions runs use the same global project ID?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mwbrooks Ooh curious ask! I reran the workflow in debug mode to find out 🐛 🔍
🔗 https://github.com/slackapi/slack-github-action/actions/runs/22938681409/job/66575655999?pr=560#step:8:261
IMO this is good to find since this project is being reused but please let me know if this should be changing in tests?