Introduction
In this guide, you'll learn about the basic components needed to create and use a packaged JavaScript action. To focus this guide on the components needed to package the action, the functionality of the action's code is minimal. The action prints "Hello World" in the logs or "Hello [who-to-greet]" if you provide a custom name.
This guide uses the GitHub Actions Toolkit Node.js module to speed up development. For more information, see the actions/toolkit repository.
Once you complete this project, you should understand how to build your own JavaScript action and test it in a workflow.
To ensure your JavaScript actions are compatible with all GitHub-hosted runners (Ubuntu, Windows, and macOS), the packaged JavaScript code you write should be pure JavaScript and not rely on other binaries. JavaScript actions run directly on the runner and use binaries that already exist in the runner image.
Warning
When creating workflows and actions, you should always consider whether your code might execute untrusted input from possible attackers. Certain contexts should be treated as untrusted input, as an attacker could insert their own malicious content. For more information, see Secure use reference.
Prerequisites
Before you begin, you'll need to download Node.js and create a public GitHub repository.
-
Download and install Node.js 24.x, which includes npm.
-
Create a new public repository on GitHub and call it "hello-world-javascript-action". For more information, see Creating a new repository.
-
Clone your repository to your computer. For more information, see Cloning a repository.
-
From your terminal, change directories into your new repository.
Shell