Slack CLI Deployment using GitHub Actions

Developing automations requires a paid plan. Don't have a paid plan? Join the Developer Program and provision a sandbox with access to all Slack features for free.

This tutorial demonstrates how to use CI/CD to facilitate automatic deployments when code changes are pushed to GitHub.

Before we begin, you'll need to do the following:

  • Create a new GitHub repository β€” any name will do.
  • Install the Slack CLI on your machine.
  • Authorize the Slack CLI to your workspace.

Once those steps have been completed, we're ready to move on to building our automated deployment app.

Create a new app

Run slack create to create a new Slack app project. Select a template to build from; in this case, hit Enter to choose the default Issue submission template.

Refer to Create or remove an app for more details.

Initial deploy

Run slack deploy to manually deploy the new app to your workspace for the first time. During the process, you'll be prompted to create a link trigger. Refer to Link triggers for more details.

Once created, copy the link and share it in a Slack channel. You'll see a button appear to start the workflow; click it to verify that the default workflow is functioning properly.

Obtain a service token

To automate subsquent deployments, we'll need to obtain a service token for the app.

Navigate to the root directory of your project and run the slack auth token command. You'll be prompted to run a slash command called slackauthticket, similar to the way you authorized your app earlier. Copy that command and run it in Slack, then copy the challenge code you receive and enter it into your terminal. You'll see a service token that starts with xoxp- β€” make sure you save this token. Note that this token is connected to a specific workspace and organization.

Add your service token to GitHub as a secret

In your GitHub repository, navigate to Settings > Secrets and variables > Actions and click New repository secret to add a new secret as follows:

  • Secret: <the xoxp- prefixed service token obtained above>

Be sure to save your changes!

Add a new deployment file with your GitHub actions workflow

Create a folder called .github/workflows/ and add a new file called deployment.yml with the following content:

name: Slack App Deployment

    branches: [ main ]

    runs-on: ubuntu-latest
    timeout-minutes: 5

    - uses: actions/checkout@v4
    - name: Install Deno runtime
      uses: denoland/setup-deno@v1
        deno-version: v1.x

    - name: Install Slack CLI
      if: steps.cache-slack.outputs.cache-hit != 'true'
      run: |
        curl -fsSL | bash

    - name: Deploy the app
      run: |
        cd gh-actions-demo/
        slack deploy -s --token $SLACK_SERVICE_TOKEN

This file instructs the Slack CLI to deploy the latest revision of your repository to the Slack platform when any changes are pushed to the main branch.

You can go with any other Linux option you prefer for the GitHub-hosted runner; refer to About GitHub-hosted runners for more details.

Test it out

To test it out, make a PR and push some changes to the main branch. If the GitHub Actions job successfully completes, your app should now be available in your workspace.

Your GitHub repository is now set up for team collaboration! Your team members can review code changes by submitting PRs, and once these are merged into the main branch, the changes will be deployed automatically. Should you need to reverse a deployment automatically, you can create a reverting PR and quickly merge that.

Further reading

Check out these articles to expand your knowledge and skills of automated deployments and the Slack CLI:

➑️ CI/CD overview and setup

➑️ CI/CD authorization

Have 2 minutes to provide some feedback?

We'd love to hear about your experience building Slack automations. Please complete our short survey so we can use your feedback to improve.

Connect services to your workflows
Use connectors with Workflow Builder and custom functions today