Test a New Github Action in Its Repository with a Custom Workflow

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet

In this lesson, you'll learn how to test a new Github Action within its own repository using a custom NodeJS workflow. We'll walk through setting up a new workflow using Github Actions and configure the workflow to run using the code from the repository.

Colby Fayock: [0:00] We're going to start off with a new custom Action in GitHub. Our Action runs a simple Node.js script that logs "Hello, world!" In order to test our custom Action, we can create a workflow just like any other action.

[0:09] Let's first start off by using the set up your workflow yourself. GitHub provides us a lot of configurations by default, so let's update this a bit. First, I'm going to rename the file to hello-world. I'm also going to change the name to Hello World. Instead of just on the master branches, I'm going to tell it to trigger on push and pull_request, so that it triggers on all branches.

[0:28] Next, for our job name, we can rename it from build to hello-world, again. We can keep it running on Ubuntu-latest, and we still want it to keep checking out our code. Finally, instead of the rest of these steps, we're going to remove them and we're going to say uses current directory.

[0:42] Since some of these comments are out of date, I'm going to remove some of them. You can go ahead and do the same if you'd like.

[0:47] Once we're ready to go, we can simply commit this file and commit it right to master. Once you commit that, you can see the Action immediately kick off. Once it's finished, we can look at the logs and we can see it says, "Hello, world!"

[0:56] In review, we created a new Node workflow to test our action. Inside our workflow, we had it running on push and pull_request, where it checks out the code and uses the current directory. Once we push to commit, to trigger that action, we were able to open up the logs and see, "Hello, world!"