Note: GitHub-hosted runners are not currently supported on GitHub Enterprise Server. You can see more information about planned future support on the GitHub public roadmap.
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 "Security hardening for GitHub Actions."
Prerequisites
Before you begin, you'll need to download Node.js and create a public GitHub repository.
-
Download and install Node.js 20.x, which includes npm.
-
Create a new public repository on your GitHub Enterprise Server instance 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 cd hello-world-javascript-action
cd hello-world-javascript-action -
From your terminal, initialize the directory with npm to generate a
package.jsonfile.Shell npm init -y
npm init -y