GitHub Actions: Writing JavaScript Actions

Learn how to write your own GitHub JavaScript Action! This course will empower you to begin automating customized tasks unique to your workflow.

Start GitHub Actions: Writing JavaScript Actions

GitHub Actions is a powerful platform that empowers your team to go from code to cloud all from the comfort of your own repositories.

Over the duration of this course, approximately 1 hour, you will learn the skills needed to begin using and customizing GitHub Actions in your unique workflow scenarios.

Prerequisites

We will be using Node.js to build our action and GitHub to consume our action. This presents us with a hybrid environment, the Node.js runtime environment and the virtual machine used by GitHub Actions, that you may not be used to if you've taken other Learning Lab courses.

Before we can get started there are a few things you need to setup on your local machine

  1. Install Node.js for your operating system.
  2. Ensure you have a text editor installed. I'll be using Visual Studio Code, and although you are free to use your editor of choice you should be aware that using a different editor will result in your screen not matching my examples. Here are some editor options for you:
    1. Visual Studio Code (recommended)
    2. Atom
    3. Sublime Text
  3. Lastly, you're going to need a local installation of Git so that you can interact with this repository as you write code.
Steps to complete this course 20
  1. Setup a workflow file

    Create a pull request to add a workflow

  2. Run a workflow

    Wait for GitHub to run the workflow and report back the results

  3. Add an Action reference

    Add an Action reference to the workflow file

  4. On to your development environment

    Lets prepare your environemtn to start writing Actions

  5. Creating the Action metadata

    Create an action.yml file and add necessary metatdata for our Action

  6. Create the Action entrypoint

    time to start adding code to main.js

  7. Adding input parameters

    extend your action to accept input parameters

  8. Exploring your input parameters

    view the results of adding input parameter

  9. Integrating Actions with external APIs

    Write a new Action that call an external API

  10. Prevent the workflow from running

    Comment out the lines in the workflow to prevent unwanted runs

  11. Create your new Action metadata

    Add action.yml file for new joke action

  12. Create your Actions JavaScript files

    Add joke.j and main.js to your Action

  13. Use the joke Action in a workflow

    Edit the workflow file to now use the newly created joke Action

  14. Having Actions tell a joke... or two

    Wait for your Action to present you with a joke

  15. Configure the workflow for a third Action

    Edit the workflow to accomodate the third action

  16. Write the final Action

    Create an Action that consumes output from another Action and uses Octokit

  17. Add third Actions metadata

    Create the metadata for the third Action

  18. Add third Actions JavaScript files

    Create the JavaScript files for the third Action

  19. Trigger the third Action

    Add a pull request label to trigger the workflow

  20. Wrapping things up

    Final notes before you go

Share GitHub Actions: Writing JavaScript Actions
Free

All public courses on Learning Lab are free.

Latest release

Ready to start learning?