visit
In our last two articles, we explored how to configure CI/CD for Heroku using Heroku pipelines. When viewing a pipeline within the Heroku dashboard, you can easily start a deployment or promote your code from one environment to the next with the click of a button. From the dashboard, you can monitor the deployment and view its progress.
This all works really well, assuming that you have Heroku open in your browser. But, what if you wanted to do it all from Slack?
Software engineers use a lot of apps at work. Throughout the day, we are constantly bouncing between Zoom meetings, Jira tasks, Slack conversations, GitHub, email, our calendar, and our IDE. This context switching can be exhausting and also lead to a lot of visual clutter on our monitors.
Sometimes, it’s nice to just live in Slack, and that’s why many tools offer Slack integrations. With these Slack integrations, you can monitor various processes and even use shortcut commands to trigger actions.
, the Heroku Slack integration, allows you to start and monitor deployments directly from Slack. In this article, we’ll explore some of the Slack commands it offers.
If you’d like to follow along throughout this tutorial, you’ll need a Heroku account and a GitHub account. You can , and you can .
The demo app that we will use with our Heroku pipeline in this article is deployed to Heroku, and .
We won’t go through the step-by-step process of creating a Heroku pipeline in this article. Refer to these articles for a walkthrough of creating a Heroku pipeline:
You can also read the .
Configuring your Heroku pipeline includes the following steps:
The other activities that you’ll see in those articles, such as configuring review apps, Heroku CI, or automated deployments are optional. In fact, for the purposes of this demo, I recommend not configuring automated deployments, since we’ll be using some Slack commands to start the deployments.
When you’re done, you should have a Heroku pipeline that looks something like this:
Now that you have your Heroku pipeline created, it’s time for the fun part: integrating with Slack. You can .
Clicking that link will prompt you to grant the Heroku ChatOps app permission to access your Slack workspace:
After that, you can add the Heroku ChatOps app to any Slack channel in your workspace.
After adding the app, type /h login
and hit Enter. This will prompt you to connect your Heroku and GitHub accounts. You’ll see several Heroku OAuth and GitHub OAuth screens where you confirm connecting these accounts.
(As a personal anecdote, I found that it took me several tries to connect my Heroku account and my GitHub account. It may be due to having several Slack workspaces to choose from, but I’m not sure.)
After connecting your Heroku account and your GitHub account, you’re ready to start using Heroku in Slack.
To view all deployable pipelines, you can type /h pipelines
:
To see information about any given pipeline, type /h info <PIPELINE_NAME>
. (Anything you see in angle brackets throughout this article should be replaced by an actual value. In this case, the value would be the name of a pipeline — for example, “heroku-flow-demo-pipeline”.)
To view a history of past releases for any given pipeline, type /h releases <PIPELINE_NAME>
.
This command defaults to showing you past releases for the production app, so if you want to see the past releases for the staging app, you can type /h releases <PIPELINE_NAME> in <STAGE_NAME>
, where <STAGE_NAME>
is “staging.”
Now that we know which pipelines are available, we can see information about any given pipeline along with when the code was last released for that pipeline. We’re ready to trigger a deployment.
Most engineering organizations have a Slack channel (or channels) where they monitor deployments. Imagine being able to start a deployment right from that channel and monitor it as it goes out! That’s exactly what we’ll do next.
To start a deployment to your staging environment, type /h deploy <PIPELINE_NAME> to <STAGE_NAME>
, where <STAGE_NAME>
is “staging.”
After running that command, an initial message is posted to communicate that the app is being deployed. Shortly after, you’ll also see several more messages; this time, in a Slack thread on the original message:
If you want to verify what you’re seeing in Slack, you can always check the Heroku pipeline in your Heroku dashboard. You’ll see the same information: The staging app has been deployed!
Now, let’s promote our app to production. Without the Slack commands, we could navigate to our Heroku pipeline, click the “Promote to production” button, and then confirm that action in the modal dialog that appears. However, we’d prefer to stay in Slack.
To promote the app to production from Slack, type /h promote <PIPELINE_NAME>
.
Just like with the staging deployment, an initial Slack message will be sent, followed by several other messages as the production deployment goes out:
And — voilà — the latest changes to the app are now in production!
Now, you can start and monitor Heroku app deployments all from Slack — no need to context switch or move between multiple apps.
For more use cases and advanced setups, you can also .
Happy deploying!