In our final two articles, we explored the right way to configure CI/CD for Heroku utilizing Heroku pipelines. When viewing a pipeline throughout the Heroku dashboard, you’ll be able to simply begin a deployment or promote your code from one surroundings to the subsequent with the press of a button. From the dashboard, you’ll be able to monitor the deployment and think about its progress.
This all works very well, assuming that you’ve Heroku open in your browser. However, what if you happen to wished to do all of it from Slack?
Software program engineers use a whole lot of apps at work. All through the day, we’re continually bouncing between Zoom conferences, Jira duties, Slack conversations, GitHub, electronic mail, our calendar, and our IDE. This context switching may be exhausting and likewise result in a whole lot of visible muddle on our displays.
Typically, it’s good to only dwell in Slack, and that’s why many instruments provide Slack integrations. With these Slack integrations, you’ll be able to monitor varied processes and even use shortcut instructions to set off actions.
Heroku ChatOps, the Heroku Slack integration, lets you begin and monitor deployments instantly from Slack. On this article, we’ll discover a few of the Slack instructions it provides.
Getting Began
If you happen to’d wish to comply with alongside all through this tutorial, you’ll want a Heroku account and a GitHub account. You may create a Heroku account right here, and you’ll create a GitHub account right here.
The demo app that we are going to use with our Heroku pipeline on this article is deployed to Heroku, and the code is hosted on GitHub.
Create Our Heroku Pipeline
We gained’t undergo the step-by-step course of for making a Heroku pipeline on this article. Refer to those articles for a walkthrough of making a Heroku pipeline:
You too can learn the Heroku docs for Heroku pipelines.
Configuring your Heroku pipeline contains the next steps:
- Create a GitHub repo.
- Create a Heroku pipeline.
- Join the GitHub repo to the Heroku pipeline.
- Add a staging app to the pipeline.
- Add a manufacturing app to the pipeline.
The opposite actions that you simply’ll see in these articles, corresponding to configuring overview apps, Heroku CI, or automated deployments are non-compulsory. In truth, for the needs of this demo, I like to recommend not configuring automated deployments, since we’ll be utilizing some Slack instructions to start out the deployments.
Once you’re performed, you must have a Heroku pipeline that appears one thing like this:
Instance Heroku Pipeline
Connect with Slack
Now that you’ve your Heroku pipeline created, it’s time for the enjoyable half: integrating with Slack. You may set up the Heroku ChatOps Slack app right here.
Clicking that hyperlink will immediate you to grant the Heroku ChatOps app permission to entry your Slack workspace:
Grant Heroku ChatOps entry to your Slack workspace
After that, you’ll be able to add the Heroku ChatOps app to any Slack channel in your workspace.
Add the Heroku ChatOps app
After including the app, kind /h login
and hit Enter. This may immediate you to attach your Heroku and GitHub accounts. You’ll see a number of Heroku OAuth and GitHub OAuth screens the place you verify connecting these accounts.
(As a private anecdote, I discovered that it took me a number of tries to attach my Heroku account and my GitHub account. It might be on account of having a number of Slack workspaces to select from, however I’m undecided.)
After connecting your Heroku account and your GitHub account, you’re prepared to start out utilizing Heroku in Slack.
View All Pipelines
To view all deployable pipelines, you’ll be able to kind /h pipelines
:
View all pipelines
View Pipeline Information
To see details about any given pipeline, kind /h information
. (Something you see in angle brackets all through this text ought to be changed by an precise worth. On this case, the worth can be the title of a pipeline — for instance, “heroku-flow-demo-pipeline”.)
View pipeline information
View Previous Releases
To view a historical past of previous releases for any given pipeline, kind /h releases
.
View previous releases
This command defaults to exhibiting you previous releases for the manufacturing app, so if you wish to see the previous releases for the staging app, you’ll be able to kind /h releases
, the place
is “staging”.
View previous staging releases
Deploy To Staging
Now that we all know which pipelines can be found, we will see details about any given pipeline together with when the code was final launched for that pipeline. We’re able to set off a deployment.
Most engineering organizations have a Slack channel (or channels) the place they monitor deployments. Think about having the ability to begin a deployment proper from that channel and monitor it because it goes out! That’s precisely what we’ll do subsequent.
To start out a deployment to your staging surroundings, kind /h deploy
, the place
is “staging.”
Deploy to staging
After operating that command, an preliminary message is posted to speak that the app is being deployed. Shortly after, you’ll additionally see a number of extra messages, this time in a Slack thread on the unique message:
Slack messages despatched when deploying to staging
If you wish to confirm what you’re seeing in Slack, you’ll be able to all the time test the Heroku pipeline in your Heroku dashboard. You’ll see the identical info: The staging app has been deployed!
Staging app proven within the Heroku dashboard
Promote to Manufacturing
Now, let’s promote our app to manufacturing. With out the Slack instructions, we may navigate to our Heroku pipeline, click on the “Promote to production” button, after which verify that motion within the modal dialog that seems. Nonetheless, we’d want to remain in Slack.
To advertise the app to manufacturing from Slack, kind /h promote
.
Promote to manufacturing
Similar to with the staging deployment, an preliminary Slack message might be despatched, adopted by a number of different messages because the manufacturing deployment goes out:
Slack messages despatched when selling to manufacturing
And — voilà — the most recent modifications to the app at the moment are in manufacturing!
Conclusion
Now you can begin and monitor Heroku app deployments all from Slack — no have to context change or transfer between a number of apps.
For extra use instances and superior setups, you may as well take a look at the docs.
Completely happy deploying!