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.
To follow along with this guide, you will need a Nexmo account. 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 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.
What is GitHub Actions?
Each action is a Docker container containing a single entry point. The action lives inside of a
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:
LABEL "com.github.actions.name"="Print GitHub Actor"
LABEL "com.github.actions.description"="Print the GITHUB_ACTOR environment variable to the console."
LABEL "maintainer"="Steve Crow <email@example.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.
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:
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:
Workflows can be created in either the graphical user interface (GUI) or by creating a
Link the Action Trigger to an Action
Drag the blue connector down to create your first action.
In the “Find or enter an action…” box put
nexmo-community/nexmo-sms-action@master and click the use button.
This action requires three secret variables to be defined:
NEXMO_API_KEYcontaining your Nexmo API Key.
NEXMO_API_SECRETcontaining your Nexmo API Secret.
NEXMO_NUMBERcontaining 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.
The command works by taking an argument in the form of
RECIPIENT_NUMBER The contents of the message. You can use variables like
$GITHUB_ACTOR in the arguments, which resolve upon the execution of the action.
Now, enter the following in the
$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:
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.
You should receive a text message upon saving your action and on any additional pushes to the repository.
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.