DEV Community

TJ-MD for WayScript

Posted on

Tutorial: Trigger Notifications when your Code is Deployed

Happy Friday everyone. If you have questions about this tutorial, please drop me a comment.

Introduction

Keeping your team informed about the status of your site is important, but can be hard to keep track of. Why not build an automated system that notifies you about these sorts of changes? In this tutorial, let's take a look at how we can send our team a notification whenever our code is deployed.

Prerequisites

No prerequisites but some content you might find helpful:
Working with Python
Working with Slack
Working with the GitHub trigger

Recap of Terminology

While developers will likely not need the recap, here's some terminology we'll use throughout this tutorial just in case:

  • *Production Environment* - Configurations/Settings of where your software is used by end users.
  • *Stable Branch* - The branch of your code deployed to your production environment
  • *Master Branch* - Branch which may contain new tested features, will be merged into the stable branch to be deployed to the production environment.
  • *Staging Branch* - Branch which contains new untested features, deployed to staging environment to be tested by developers.
  • *Other Branches* - Developers build new features onto their created branches before merging to staging for testing.

Notifying Upon Stable Branch Push

To send these notifications, there's a couple of different ways to do this. We are making the assumption here that your stable branch, once merged, will be automatically deployed. If this isn't the case, then you are still able to create notifications through WayScript with the use of the Python module. Of course, depending on your server provider, these specific API calls will vary.

With automatic deployments enabled, this notification script becomes very easy to make. The first thing we need to do, is to create a script and place in a GitHub Trigger.

GitHub Trigger

This trigger allows us to activate events in our script whenever certain actions happen in our denoted repo.

trigger

For us, since we want to notify our team whenever a push event happens to our staging branch, we can do this by selecting the push event type, then choosing the branch.

choosing branch

Notification of Push

Once this push occurs, this activates everything below this trigger in our workflow. We can add many different notification sources to occur. Let's use slack:

Slack

Once we add slack, we configure it to the desired channel to post the notification to. We also denote the message we want to send:

Message send

Example of the Completed Script

That's it for this one! Not many moving parts to explain. If you would like to view this script yourself, or clone it to your own WayScript account, you can find it here.

Top comments (0)