Send SMS with GitHub Actions
Tags: sms, github
Published: 2019-03-22 15:04:23

---
title: Send SMS with GitHub Actions
published: true
tags: sms, github
cover_image: https://www.nexmo.com/wp-content/uploads/2019/01/Send-SMS-with-GitHub-Actions-1200x600.png
canonical_url: https://www.nexmo.com/blog/2019/02/08/send-sms-github-actions-dr/
---
Bosses come in all shapes and sizes. Some are hands-off, letting you work to the best of your abilities. Others, take a more direct approach and measure your accomplishments solely through the code that you produce. After all, if you're not writing code then why are we paying you?

Want to show your boss just how hard you're working? Absolutely! With the power of Nexmo and GitHub Actions, you can make sure that an excellent annual review and a sizable pay raise are in order.

## Prerequisites

To follow along with this guide, you will need a Nexmo account. [Sign up](https://dashboard.nexmo.com/sign-up) now if you don't have one.

Upon signing up, you will receive an API key and secret. You will need these for a later step. Additionally, you will need to [purchase an SMS enabled number](https://www.nexmo.com/products/phone-numbers) to be able to send messages.

At the time of writing, GitHub Actions is currently in public beta. If you aren't a member of the beta, you will need to [apply for the beta](https://github.com/features/actions/signup/).

## What is GitHub Actions?

[GitHub Actions](https://developer.github.com/actions/) is a new tool from GitHub in which individual actions are combined to make a workflow that performs on different [trigger event types](https://developer.github.com/v3/activity/events/types/).

Each action is a Docker container containing a single entry point. The action lives inside of a `Dockerfile` with `LABEL` instructions providing information about the action.

For example, let's say you wanted to print out the name of the user (referred to as the GitHub Actor) to the console. You would create a repository that contains a `Dockerfile` with the following contents:

```dockerfile
FROM alpine:3.8

LABEL "com.github.actions.name"="Print GitHub Actor"
LABEL "com.github.actions.description"="Print the GITHUB_ACTOR environment variable to the console."
LABEL "com.github.actions.icon"="user"
LABEL "com.github.actions.color"="blue"

LABEL "repository"="https://github.com/cr0wst/display-github-actor-action"
LABEL "homepage"="https://smcrow.net"
LABEL "maintainer"="Steve Crow <steve.crow@nexmo.com>"

ENTRYPOINT ["sh", "-c", "echo $GITHUB_ACTOR"]
```

This entire action runs the command `echo $GITHUB_ACTOR` where `$GITHUB_ACTOR` is an environment variable that GitHub provides to the container containing the user who triggered the action.

> For more information on Docker see this [Docker Overview](https://docs.docker.com/engine/docker-overview/).

The advantage of GitHub Actions comes in creating reusable actions that others can use in their workflows.

## Creating Your First Workflow

For this guide you will be creating a new repository with a workflow that sends your boss a text message every time a push is received.

### Create a Repository

First, start by creating a new repository:

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/create-new-repo.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/create-new-repo.png" alt="Creating a new repository on GitHub." width="1480" height="878" class="alignnone size-full wp-image-26404" /></a>

### Create a New Workflow

After you create your repository, you will need to navigate to the actions tab where you will see a button to create a new workflow:

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/create-first-workflow.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/create-first-workflow.png" alt="Create your first workflow on GitHub" width="1224" height="662" class="alignnone size-full wp-image-26401" /></a>

Workflows can be created in either the graphical user interface (GUI) or by creating a `workflow` file.

### Link the Action Trigger to an Action

Drag the blue connector down to create your first action.

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/create-action.gif"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/create-action.gif" alt="Drag the connector to create a new action" width="1896" height="792" class="size-full wp-image-26398" /></a>

The action that you will be bringing in is the [Nexmo SMS Action](https://github.com/nexmo-community/nexmo-sms-action). This action uses the [Nexmo CLI](https://github.com/Nexmo/nexmo-cli) to send text messages.

In the "Find or enter an action..." box put `nexmo-community/nexmo-sms-action@master` and click the use button.

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/choose-nexmo-action.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/choose-nexmo-action.png" alt="Enter the Nexmo Send SMS Action" width="764" height="646" class="size-full wp-image-26395" /></a>

This action requires three secret variables to be defined:

- `NEXMO_API_KEY` containing your Nexmo API Key.
- `NEXMO_API_SECRET` containing your Nexmo API Secret.
- `NEXMO_NUMBER` containing the number from which to send the message.

I recommend storing your boss' number in another secret variable.

Scroll down and enter your secret variables. I will be using the `BOSS_NUMBER` environment variable to store the number that will be receiving the SMS. 

For testing purposes, and probably production purposes, I wouldn't recommend using your boss's _actual_ number. Try it with your phone number first. The phone number must be in international format without any spaces or special characters separating the numbers. For example, 15551239876.

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/define-secrets.gif"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/define-secrets.gif" alt="Define your secrets." width="766" height="792" class="alignnone size-full wp-image-26407" /></a>

The command works by taking an argument in the form of `RECIPIENT_NUMBER The contents of the message.` You can use variables like `$BOSS_NUMBER` and `$GITHUB_ACTOR` in the arguments, which resolve upon the execution of the action.

Now, enter the following in the `args` box:

```text
$BOSS_NUMBER Hey boss! Just letting you know that I, $GITHUB_ACTOR, just pushed some code.
```

Now you can hit the done button and save your action with the "start commit" button in the upper-right corner:

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/save-changes.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/save-changes.png" alt="Save your action" width="918" height="852" class="alignnone size-full wp-image-26419" /></a>

Saving the action is a `push` in and of itself. If you look in the actions tab, you can see the status of your action.

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/workflow-in-progress.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/workflow-in-progress.png" alt="See the status of the action in progress." width="724" height="608" class="alignnone size-full wp-image-26422" /></a>

You should receive a text message upon saving your action and on any additional pushes to the repository.

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/hey-boss-sms.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/hey-boss-sms.png" alt="Text message which states that you are working." width="1096" height="122" class="alignnone size-full wp-image-26413" /></a>
## Conclusion

Soon enough your boss will start to realize the true value you bring to the company. Your work will be filling up their text message inbox and sending them into a state of "my direct reports are amazing" euphoria.

<a href="https://www.nexmo.com/wp-content/uploads/2019/01/happy-boss.png"><img src="https://www.nexmo.com/wp-content/uploads/2019/01/happy-boss.png" alt="You being praised by all of your bosses." width="640" height="448" class="alignnone size-full wp-image-26410" /></a>

Check out the [hey-boss-im-working](https://github.com/cr0wst/hey-boss-im-working/) repository for a full example of this workflow. You can also find it as part of our [Nexmo Extend Catalog](https://developer.nexmo.com/extend/).