Technique 4: Slack CLI Command
A service token is used to install and run Slack CLI commands directly from a GitHub Actions workflow with this technique.
Setup
For details on how to setup this technique in GitHub Actions, read the setup section of the docs.
Example workflows
- Deploy an app: Deploy to Slack on push to the main branch.
- Validate the app manifest: Check the app manifest on pull requests.
- Manage a collaborator: Add or remove an app collaborator using CLI and API techniques together.
Deploy an app
Deploy a Slack app when changes are pushed to the main branch. This example uses a service token to authenticate the deploy command.
Related files:
deploy.yml: GitHub Actions workflow.
Validate the app manifest
Run manifest validation on pull requests to catch configuration issues early. This example checks the app manifest file in the repository.
Related files:
manifest.yml: GitHub Actions workflow.
Manage a collaborator
Add or remove an app collaborator using a manually triggered workflow with workflow_dispatch. This example combines the Slack API technique (users.lookupByEmail, chat.postMessage) with the CLI technique (collaborators add/remove) to look up a user by email, update collaborators, and post a confirmation message.
Related files:
collaborators.yml: GitHub Actions workflow.