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 complete this tutorial, you will need a Vonage API account. If you don’t have one already, you can sign up today and start building with free credit. Once you have an account, you can find your API Key and API Secret at the top of the Vonage API Dashboard.
This tutorial also uses a virtual phone number. To purchase one, go to Numbers > Buy Numbers and search for one that meets your needs.
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.
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:
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 <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.
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.
First, start by creating a new repository:
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
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.