DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for Alexa custom skill workflow using Github Actions
sania-dsouza
sania-dsouza

Posted on

Alexa custom skill workflow using Github Actions

My Workflow

Project link:

DevTo - Github Actions : Hackathon 2021

This repo and project was created as an entry into the DevTo-Github Hackthon 2021, which focused on integrating Github Actions in a project.

Category chosen: Interesting IoT

Getting Started

  1. Ensure you have node installed. Find out: node -v
  2. Clone the repo : git clone
  3. Install dependencies : npm install
  4. This project uses Jovo to create the Alexa skill. Jovo provides a 'debugger' that helps to view and test interactions with Alexa. Run it using jovo run
  5. Click Launch to start the app
  6. The Nutri Planner app must open and allow you to interact with this skill

Note: The app currently just allows the user to choose from a given list of responses. This is extendable to accept any custom user input to mimic regular Alexa behavior.

Github Actions integration

The Github Actions workflow is the .github/workflows/node.js.yml file The workflow is designed to function…

License: MIT

What is this about?

This project is the development of a custom Alexa skill using the Jovo platform that 'enables professional teams to build and run apps that work across smart speakers, the web, mobile, and more.'

  • The app is a nutrition planner that takes meal inputs from the user; the app currently accepts input from the user for breakfast, lunch and dinner and provides hard-coded replies for the same right now (see picture below as seen in the Jovo debugger)
  • While not implemented in this project, the goal is to save the user's input and count the number of calories consumed by the user in a day, for health monitoring.
  • Aside from creating the app and using Github Actions for the workflow, the skill was built and deployed to the Alexa Developer Console too for registration and further testing (a screenshot is attached later in this post).
  • Now for where Github Actions comes in!
    The following Actions have been used throughout the workflow:
    ~ checkout@v2 : To checkout code
    ~ setup-node@v2 : To get node installed
    ~ upload-artifact@v2 : To upload important artifacts such as the whole skill code and test reports to the workflow run
    ~ codecov-action@v2 : To report test coverage code to Codecov -- the code coverage tool
    ~ appleboy/lambda-action@master : To deploy zipped code to AWS Lambda

  • A number of secrets have been used to run the workflow as expected such as the AWS_ACCESS_KEY_ID, AWS_REGION etc.

  • The list of jobs in the workflow are below:
    ~ build
    ~ static-code-analysis
    ~ unit-test
    ~ code-coverage
    ~ virtual-alexa-tests
    ~ deploy-skill
    ~ store-artifacts

Codecov:
Codecov

Jovo Debugger:
Jovo Debugger Test run

Github Actions run:
Latest Workflow run

Submission Category :

Interesting IoT

Yaml File:

name: Node.js CI

on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build:
    runs-on: ubuntu-latest
    name: Build
    strategy:
      matrix:
        node-version: [14.x]

    steps:
    - uses: actions/checkout@v2
    - name: Use Node.js ${{ matrix.node-version }}
      uses: actions/setup-node@v2
      with:
        node-version: ${{ matrix.node-version }}
        cache: 'npm'
    - run: npm install

  static-code-analysis: 
    runs-on: ubuntu-latest
    name: Static code analysis 
    needs: build
    steps: 
    - name: Checkout
      uses: actions/checkout@v2
    - run: |
        npm install
        npm run eslint

  unit-test: 
    runs-on: ubuntu-latest
    name: Unit test using Jest
    needs: static-code-analysis
    steps: 
    - name: Checkout
      uses: actions/checkout@v2
    - run: |
        npm install
        npm run test
    - name: Upload results
      uses: actions/upload-artifact@v2
      with:
        name: unit-test-report
        path: reports/test-report.html

  code-coverage: 
    runs-on: ubuntu-latest
    name: Code Coverage using Codecov
    needs: unit-test
    steps:
    - name: Checkout
      uses: actions/checkout@v2
    - run: |
        npm install
        npm run codecov
    - name: Codecov push results
      uses: codecov/codecov-action@v2
      with:
          token: ${{ secrets.CODECOV_TOKEN }} 

  virtual-alexa-tests: 
    runs-on: ubuntu-latest
    name: Test on Virtual Alexa
    needs: code-coverage
    steps: 
    - name: Checkout
      uses: actions/checkout@v2
    - run: |
        npm install
        npm run test-virtual
    - name: Upload results
      uses: actions/upload-artifact@v2
      with:
        name: virtual-test-report
        path: reports/test-report.html  

  deploy-skill: 
    name: Build and deploy lambda
    needs: virtual-alexa-tests
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Install dependencies and zip folder contents
        run: |
          npm install && zip -r bundle.zip .
      - name: deploy zip to aws lambda
        uses: appleboy/lambda-action@master
        with:
          aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws_region: ${{ secrets.AWS_REGION }}
          function_name: 'devto-gha-hack2021-dev-handler'
          zip_file: bundle.zip

  store-artifacts:
    name: Store skill code
    if: always()
    runs-on: ubuntu-latest
    needs: deploy-skill
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Upload code
        uses: actions/upload-artifact@v2
        with:
          name: code
          path: ${{ github.workspace }}
Enter fullscreen mode Exit fullscreen mode

Additional Resources / Info

A screenshot of the skill in action on the Alexa Developer Console:

Alexa Developer skill

Author:

saniadsouza image

Top comments (0)

12 Gorgeous UI Components for Your Design Inspiration

>> Check out this classic DEV post <<