Tutorial: Create a Slack Notification when Your GitHub Repo has a New Commit
Tags: tutorial, beginners, github, slack
Published: 2020-04-28 13:13:24

*This tutorial uses WayScript, a rapid development platform for devs like you. The beauty of WayScript is that all scripts can be shared privately or publicly. A completed script of this tutorial can be found [here](https://wayscript.com/user/derricks/0GZNvnjh).*

##Introduction
Whether your team size is large or small, monitoring commits to your Github repositories can be a challenge. With numerous branches, it becomes easier to miss those important commits that you need to see. With WayScript, we can easily build a system that with notify us, on our chosen platform, about new pushes to certain branches within our repositories. In this example, let's build an automated system that will send us a slack notification whenever there's a new commit to our master branch.

##Prerequisites
No prerequisites but some content you might find helpful:
[Working with Slack](https://docs.wayscript.com/library/modules/slack)
[Working with GitHub Triggers](https://docs.wayscript.com/library/triggers/github-trigger)

##Activating a Script with GitHub Events
WayScript provides a way for us to run our scripts whenever a specified event happens on GitHub. We can monitor several things, such as push events, issues, pull requests, and more. To activate this trigger, we first need to pull it into our workflow.

![Workflow](https://cdn.wayscript.com/blog_img/75/1.png)

Once we have this trigger in, we have a menu to the left that allows us to visually select the interacts we want to monitor on GitHub to activate our workflow.

To monitor for pushes to master, let's configure our trigger settings to something like this:

![trigger](https://cdn.wayscript.com/blog_img/75/2.png)

These settings will cause our actions below to activate whenever a new push to master occurs. Finally, we're able to select outputs from this trigger to use in other steps if we want. Let's use an output of the commit messages and pass this to slack for the notification.

![Output](https://cdn.wayscript.com/blog_img/75/3.png)

##Writing a Slack Notification
To write to Slack, we'll use a slack module. We can drag this in from the module selection, and place it below our Github trigger.

![Slack module](https://cdn.wayscript.com/blog_img/75/4.png)

The slack module allows us to easily write to the slack channel of our choice, with dynamic messages. We can use the commit text from the pushes to master to populate our messages.

##Configuring the Slack Notification
Opening up the settings, we'll fill them out with something like this:

![settings](https://cdn.wayscript.com/blog_img/75/5.png)

Next we can drag the variable text from our github message into the message text box.

![variable text](https://cdn.wayscript.com/blog_img/75/6.png)

Now, any time a push to our designated branch occurs, we'll receive a slack notification that has the message of the commits to our slack channel.

##Questions, Concerns?
If there's any questions feel free to message us on discord. We're happy to help! If you want to see this full script template, you can find it [here](https://wayscript.com/user/derricks/0GZNvnjh).

**CHECK OUT THE VIDEO:** Here's a [link to the video](https://youtu.be/B0lTRKebIZo) for this tutorial.