If you’re looking for a quick way to create a nodejs action, run
npx actions-toolkit <your-action-name>to scaffold an empty action
Github actions are standard Docker images with a small amount of additional metadata. As it’s a Docker image it must start with a
FROM entry. In this case we’re going to inherit from the
node:slim image as we build actions with
LABEL instruction allows you to add context when your action is shown in Github’s visual workflow editor.
LABEL "com.github.actions.name"="Your Action Name" LABEL "com.github.actions.description"="This is a list" LABEL "com.github.actions.icon"="activity" LABEL "com.github.actions.color"="red"
There are 282 different values available for
com.github.actions.icon (as of publishing). Take a look at https://feathericons.com/ for the full list.
com.github.actions.color sets the background colour of your icon, and can be one of the following:
For more information about the
LABEL command see the github docs.
Once you’ve added this metadata you can use standard Docker commands to build an image. In this case we’re using the
node:slim image as a base, installing all our dependencies with
npm and setting an entrypoint of
COPY package*.json ./ RUN npm ci COPY . . ENTRYPOINT ["node", "/index.js"]
At this point you can run implement
index.js using any libraries you need before uploading your action to a Github repo.
For an example action built following this blog post take a look at debug, which outputs all available
GITHUB_ environment variables and the event payload used to trigger the action.