Open hectorsector opened 5 years ago
We don't always have to dig into the Actions tab to get the deployment URL, though. One of the best things about defining workflows with GitHub Actions is the ability to use multiple services in a single place to make your life easier.
Let's practice this by sending yourself an SMS notification when a deployment occurs. You'll need to create an account on Nexmo for this next step.
On Nexmo:
NEXMO_API_KEY
NEXMO_API_SECRET
NEXMO_NUMBER
.github/main.workflow
on this branch.nexmo-community/nexmo-sms-action@master
sms notify
NEXMO_API_KEY
: the API key provided to you by NexmoNEXMO_API_SECRET
: the API secret provided to you by NexmoNEXMO_NUMBER
: the phone number provided to you by NexmoPHONE
: your phone number, the number you wish to notify, preceded by the country code$PHONE A deployment just occurred check it out
You should get a notification soon! But it won't include the URL of your deployment. That's because you haven't supplied the Nexmo SMS action with the URL. To do this, we need to save that URL in the deploy action, and access it again in the SMS action. This is possible as a result of the runtime environment that is created when actions run in the Docker container.
main.workflow
file on this branch.deploy > deploy.txt
.
-e GITHUB_SHA=$GITHUB_SHA -e GITHUB_ACTOR=$GITHUB_ACTOR deploy > deploy.txt
We've now captured the output from the deployment action, although we can't see it. It is stored in a file called deploy.txt
in the Docker container. We can use the captured deployment URL currently sitting in our runtime environment to include it in the SMS notification.
main.workflow
file on this branch.sms notify
action.cat deploy.txt
to the args
field.
$PHONE A deployment just occurred at `cat deploy.txt` check it out
By filling in the
args
field, you're passing arguments to the action, which is running in a Docker container.In this case, we passed in arguments with the
-e
option. This allows us to set environment variables in Zeit Now.When an action runs, some environment variables are set by GitHub and available in the runtime environment. Although these are available in the Docker container, they need to be explicitly passed to Zeit Now if we want our deployed application to make use of them.
Get your deployment URL by going into the Actions tab. You can then visit it to examine the newly deployed app. You'll see that it now looks something like this: