DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Low-Code Development: Leverage low and no code to streamline your workflow so that you can focus on higher priorities.

DZone Security Research: Tell us your top security strategies in 2024, influence our research, and enter for a chance to win $!

Launch your software development career: Dive head first into the SDLC and learn how to build high-quality software and teams.

Open Source Migration Practices and Patterns: Explore key traits of migrating open-source software and its impact on software development.

Related

  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline
  • Pipeline of an Alexa Skill with GitHub Actions
  • Enhance IaC Security With Mend Scans
  • How GitHub Codespaces Helps in Reducing Development Setup Time

Trending

  • Theme-Based Front-End Architecture Leveraging Tailwind CSS for White-Label Systems
  • Build an Advanced RAG App: Query Rewriting
  • Next-Gen Lie Detector: Stack Selection
  • Tenv v2.0: The Importance of Explicit Behavior for Version Manager
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Deployment
  4. Heroku for ChatOps: Start and Monitor Deployments From Slack

Heroku for ChatOps: Start and Monitor Deployments From Slack

Learn how to start and monitor Heroku app deployments all from Slack — no need to context switch or move between multiple apps.

By 
Tyler Hawkins user avatar
Tyler Hawkins
DZone Core CORE ·
Jun. 06, 24 · Tutorial
Like (1)
Save
Tweet
Share
2.8K Views

Join the DZone community and get the full member experience.

Join For Free

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.

Heroku ChatOps, 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.

Getting Started

If you’d like to follow along throughout this tutorial, you’ll need a Heroku account and a GitHub account. You can create a Heroku account here, and you can create a GitHub account here.

The demo app that we will use with our Heroku pipeline in this article is deployed to Heroku, and the code is hosted on GitHub.

Create Our Heroku Pipeline

We won’t go through the step-by-step process for creating a Heroku pipeline in this article. Refer to these articles for a walkthrough of creating a Heroku pipeline:

  • How to create a Heroku pipeline with a staging and production app and a single main branch
  • How to create a Heroku pipeline with a staging and production app with a dev branch and a main branch

You can also read the Heroku docs for Heroku pipelines.

Configuring your Heroku pipeline includes the following steps:

  1. Create a GitHub repo.
  2. Create a Heroku pipeline.
  3. Connect the GitHub repo to the Heroku pipeline.
  4. Add a staging app to the pipeline.
  5. Add a production app to the pipeline.

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:

Example Heroku pipeline

Example Heroku Pipeline

Connect to Slack

Now that you have your Heroku pipeline created, it’s time for the fun part: integrating with Slack. You can install the Heroku ChatOps Slack app here.

Clicking that link will prompt you to grant the Heroku ChatOps app permission to access your Slack workspace:

Grant Heroku ChatOps access to your Slack workspace

Grant Heroku ChatOps access to your Slack workspace

After that, you can add the Heroku ChatOps app to any Slack channel in your workspace.

Add the Heroku ChatOps app

Add the Heroku ChatOps app

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.

Connect your Heroku and GitHub accountsConnect your Heroku and GitHub accounts

View All Pipelines

To view all deployable pipelines, you can type /h pipelines:

View all pipelines

View all pipelines

View Pipeline Info

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”.)

View pipeline info

View pipeline info

View Past Releases

To view a history of past releases for any given pipeline, type /h releases <PIPELINE_NAME>.

View past releases

View past releases

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”.

View past staging releases

View past staging releases

Deploy To 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.”

Deploy to staging

Deploy to 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:

Slack messages sent when deploying to staging

Slack messages sent when deploying to staging

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!

Staging app shown in the Heroku dashboard

Staging app shown in the Heroku dashboard

Promote to Production

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>.

Promote to production

Promote to production

Just like with the staging deployment, an initial Slack message will be sent, followed by several other messages as the production deployment goes out:

Slack messages sent when promoting to production

Slack messages sent when promoting to production

And — voilà — the latest changes to the app are now in production!

Conclusion

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 check out the docs.

Happy deploying!

GitHub Pipeline (software) Slack (software)

Published at DZone with permission of Tyler Hawkins. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Deploy MuleSoft App to CloudHub2 Using GitHub Actions CI/CD Pipeline
  • Pipeline of an Alexa Skill with GitHub Actions
  • Enhance IaC Security With Mend Scans
  • How GitHub Codespaces Helps in Reducing Development Setup Time

Partner Resources


Comments

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: