Create a New Github Action That Logs Hello World with Javascript and NodeJS

Colby Fayock
InstructorColby Fayock
Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 3 years ago

In this lesson, you'll learn how to create a brand new Github Action from scratch using Javascript. Running on Nodejs, we'll create a new script that logs "Hello, world!", configure the Action registration information, and initialize it as an npm package so that we can prepare to publish it to the world.

Colby Fayock: [0:00] We're going to start off with an empty GitHub repository. Once we open our code editor, we can see that we have absolutely no files to start. Our goal, we'll build and create a simple node script using JavaScript that says, "Hello, world!"

[0:09] To start that we first need a file, so let's open a new file. We can name it index.js. Inside we can console.log('Hello, world!'). To test this out, we can open up our terminal and run node index.js, and see it say "Hello, world!"

[0:24] Now, we have the script that we want to run, but now we have to make in an npm package. Inside our terminal we want to run npm init. Once you run init, it will ask you a few questions, and we could probably use most of the defaults here. Once you're at the end, you can type yes for Is it OK? Once you're done, you can see that it created a package.json for us with all of our information.

[0:41] The last file that we'll need for our action is an action.yml. Let's go ahead and create a new file. We can save it as action.yml. Inside we want to add a few attributes. We want to add name, which we'll call Hello World and a description, which we can say Saying hello to the world! You can even put your author name. For me, I'm Colby Fayock. My email is hello@colbyfayock.com.

[1:05] For the important part, we want to add a runs attribute. The first property we want add is using. This is our environment, so we want to say node12. We also want to specify a main, which is index.js file.

[1:16] Once you add these files, commit them and push them, we can see them in our repo where we now see it Publish this Action to Marketplace.

[1:22] In review, we started off by creating a script that logs 'Hello, world!' Next, we used npm to initialize our package. Finally, to register our Action, we created an action.yml file where we specified our configuration. Once we pushed those files to GitHub, we're now ready to use our Action.

egghead
egghead
~ an hour ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today