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 free course Join 1754 others!

social preview

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 you will learn the skills needed to begin using and customizing GitHub Actions to fit your unique workflow scenarios.

What you'll learn

In this course you will learn how to:

  • Consume actions within a workflow file
  • Create custom JavaScript based actions
  • Publish your newly created action to the marketplace

You'll know the answers to questions like:

  • What is a workflow?
  • What are actions?
  • What is action metadata?
  • What are GitHub Actions capable of?

What you'll build

screenshot of a pull request in the course with instructions on how to fetch a joke from the API, a second screenshot of a workflow running and outputting the joke: "Guy told me today he did not know what cloning is. I told him, that makes 2 of us."

In this course you will build three actions that each accomplish different tasks designed to demonstrate the flexibility of creating and consuming JavaScript Based Actions.

First, you will start with the traditional "Hello World!" program which will teach you where to find the output of a workflow run. You will then modify this "Hello World!" action to accept input parameters which allow the action to be more dynamic.

Second, you will write an action that call upon an external API to retrieve a fact about cats and prints it to the workflows output. You will then modify this cat fact action to set the retrieved data as output for another action in the workflow to consume.

Lastly, you will write a third action that will open an issue in your repository making the cat fact available to everyone. You will learn how to use the output of previous actions as input for current actions in this step.

Prerequisites

We first recommend taking the following courses:

Projects used

This makes use of the following open source projects. Consider exploring these repos and maybe even making contributions!

Audience

Developers, DevOps Engineers, students, teams

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. Prep the workflow

    Prepare the workflow for your future action

  4. Add an Action reference

    Add an Action reference to the workflow file

  5. On to your development environment

    Lets prepare your environment to start writing Actions

  6. Creating the Action metadata

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

  7. Create the Action entrypoint

    Add code to main.js file

  8. Exploring your input parameters

    View the results of adding input parameter

  9. Integrating Actions with external APIs

    Write a new Action that calls an external API

  10. Prevent the workflow from running

    Comment out the lines in the workflow to prevent unwanted runs

  11. Install dependencies for the second action

    Create a directory for your new action dependencies

  12. Create your new Action metadata

    Add action.yml file for new joke action

  13. Create your Actions JavaScript files

    Add joke.js and main.js to your Action

  14. Use the joke Action in a workflow

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

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

    Wait for your Action to present you with a joke

  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

Tags
JavaScript
API
Actions toolkit
GitHub Secrets
Workflows
Share this course
Average time to complete

533 minutes

Free

All public courses on Learning Lab are free.

Latest release

Learning Paths that include this course

Users who took this course also took

What is GitHub Learning Lab?

Learn new skills by completing fun, realistic projects in your very own GitHub repository.