DEV Community


Posted on

Tell Alexa to trigger your deployment

My Workflow

The "on voice" workflow uses the workflow_dispatch event to trigger the github action via the github rest api. This action is just a proof of concept for allowing you to interact with your repo by voice, and is not used anywhere except the repo I've created for this actionsHackathon submissions.

Submission Category:

Interesting IoT

Yaml File or Link to Code


Additional Resources / Info

The code used in the action is really nothing special. I've left it as the "default" action template but just changed the event trigger to "workflow_dispatch". This allows me to call the rest api targeted at the "onvoice.yml" file, which in turn would kick off any deployment defined within. The idea here is that you could tell alexa to trigger {your project name} deployment, and have it kickoff this process.

To set this up, you'll need an IFTTT account, and add the Alexa service.

Alt Text

Once you connect the Alexa service, setup a new trigger for "say a specific phrase".

Alt Text

Fill out the form with something like "my deployment" - when you interact with alexa you'll say "Alexa, trigger my deployment"
Alt Text

Then, for the action - search for "webhook" and set the action as "make a web request"
Alt Text

This is where things got a little funky. I could not get this web request action to properly authenticate to the github rest api. I tried doing basic auth in the url with which works with curl but not via ifttt. Unfortunately the ifttt interface doesn't give you a lot of options for customizing your http request, so I ended up setting up an azure function to bypass this problem. My webhook instead calls the function app URL, which in turn calls the workflow dispatch. The curl for the call looks like this:

curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \{USER}/{REPOSITORY}/actions/workflows/{WORKFLOW_ID_OR_YML_FILE_NAME}/dispatches \
  -d '{"ref":"{BRANCH_NAME}"}' \
  -u {USER}:{PAT}
Enter fullscreen mode Exit fullscreen mode

Anything surrounded with curly braces {} would be specific to your account/repository. Learn how to make a Personal Access Token (PAT) here: Create a PAT. You can read up on the workflow_dispatch event here: Workflow Dispatch Trigger Event and the github rest api for calling the workflow dispatch event here: Workflow Dispatch Rest Api Call.

Top comments (0)