You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Imagine youβve got a repetitive task youβd love to automate. You've searched through the GitHub Marketplace for existing actions that might help, you come up empty-handedβ¦
Maybe thatβs because your task is a bit too unique π
GENERATING DAD JOKES! π
Since no pre-built action exists for your quirky automation needs, it's time to roll up your sleeves and create your own!
β¨οΈ Activity: Set up your development environment
Let's use GitHub Codespaces to set up a cloud-based development environment and work in it for the remainder of the exercise!
Right-click the below button to open the Create Codespace page in a new tab. Use the default configuration.
Confirm the Repository field is your copy of the exercise, not the original, then click the green Create Codespace button.
β Your copy: /marnheus/skills-write-javascript-actions
β Original: /skills/write-javascript-actions
Wait a moment for Visual Studio Code to load in your browser.
Verify that Node.js is available by opening a terminal and running:
node --version
npm --version
Having trouble? π€·
Make sure you selected your personal copy of the repository, not the original template.
If the Codespace fails to start, try refreshing the page and creating a new one.
Node.js and npm should be pre-installed in the development environment.
β¨οΈ Activity: Initialize Project
Now that your Codespace is ready, let's initialize a new Node.js project and install the dependencies needed for your Dad Jokes action.
Within your GitHub Codespace terminal window initialize a new project:
Nice! Now that we have the project initialized and dependencies installed, it's time to create the source files for your Dad Jokes GitHub Action.
π Theory: The GitHub Actions Toolkit
The @actions/core library is the main library from the GitHub Actions Toolkit, a collection of packages for building JavaScript GitHub Actions. It provides essential methods to interact with the GitHub Actions runtime environment, accept action inputs, and produce outputs for other workflow steps.
Tip
The GitHub Actions Toolkit includes other useful libraries like @actions/github for interacting with the GitHub API and @actions/artifact for uploading and downloading artifacts.
Now that you've created the source files for your Dad Jokes GitHub Action and tested it locally, it's time to bundle the action so it can be used in GitHub workflows.
π Theory: Bundling Your Action
When someone uses your action in their workflow, GitHub downloads and executes it as a complete package of code. This means you must include any package dependencies required to run the JavaScript code, such as the @actions/core and request-promise packages your action uses.
Rather than committing your node_modules directory (which causes problems with repository size and performance), you can use bundling tools like @vercel/ncc to combine your code and dependencies into a single dist/index.js file for distribution.
β¨οΈ Activity: Build Setup & Bundle
Add a new build script to package.json (inside the existing scripts object):
Nice! Now that we have the project initialized and dependencies installed, it's time to create the source files for your Dad Jokes GitHub Action.
π Theory: The GitHub Actions Toolkit
The @actions/core library is the main library from the GitHub Actions Toolkit, a collection of packages for building JavaScript GitHub Actions. It provides essential methods to interact with the GitHub Actions runtime environment, accept action inputs, and produce outputs for other workflow steps.
Tip
The GitHub Actions Toolkit includes other useful libraries like @actions/github for interacting with the GitHub API and @actions/artifact for uploading and downloading artifacts.
Great work! π You've successfully bundled your Dad Jokes GitHub Action into a single file.
Now it's time to create the action metadata file - this special file tells GitHub exactly how to use your action when someone includes it in their workflow!
π Theory: Action Metadata
Every GitHub Action requires a metadata file that defines how the action should be executed and what parameters it accepts.
Create action.yml at the repository root (same level as package.json).
name: "Joke Action"description: "Fetches a random joke and exposes it as an output"outputs:
joke:
description: "The fetched joke text"runs:
using: node24main: dist/index.js
Commit and push the action metadata file to the main branch:
Activity
github-actions commentedon Feb 4, 2026
Step 1: Setting up the project
Imagine youβve got a repetitive task youβd love to automate. You've searched through the GitHub Marketplace for existing actions that might help, you come up empty-handedβ¦
Maybe thatβs because your task is a bit too unique π
GENERATING DAD JOKES! π
Since no pre-built action exists for your quirky automation needs, it's time to roll up your sleeves and create your own!
β¨οΈ Activity: Set up your development environment
Let's use GitHub Codespaces to set up a cloud-based development environment and work in it for the remainder of the exercise!
Right-click the below button to open the Create Codespace page in a new tab. Use the default configuration.
Confirm the Repository field is your copy of the exercise, not the original, then click the green Create Codespace button.
/marnheus/skills-write-javascript-actions/skills/write-javascript-actionsWait a moment for Visual Studio Code to load in your browser.
Verify that Node.js is available by opening a terminal and running:
Having trouble? π€·
β¨οΈ Activity: Initialize Project
Now that your Codespace is ready, let's initialize a new Node.js project and install the dependencies needed for your Dad Jokes action.
Within your GitHub Codespace terminal window initialize a new project:
Install the required dependencies:
Review
package.jsonto confirm dependencies are listed in thedependenciessection.Open the
.gitignorefile and add an entry to exclude thenode_modulesdirectory from being tracked by Git:We don't want to commit
node_modulesbecause it contains thousands of files that would bloat the repository.Commit and push your changes:
With the changes pushed to GitHub, Mona will check your work and share the next steps.
Having trouble? π€·
npm init -y.node_modules/to the repository; ensure it's listed in.gitignore.github-actions commentedon Feb 4, 2026
Step 1 - Passed β
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Preparing content for step 2! One moment... π€
github-actions commentedon Feb 4, 2026
Step 2: Create Source Files & Run Locally
Nice! Now that we have the project initialized and dependencies installed, it's time to create the source files for your Dad Jokes GitHub Action.
π Theory: The GitHub Actions Toolkit
The
@actions/corelibrary is the main library from the GitHub Actions Toolkit, a collection of packages for building JavaScript GitHub Actions. It provides essential methods to interact with the GitHub Actions runtime environment, accept action inputs, and produce outputs for other workflow steps.Tip
The GitHub Actions Toolkit includes other useful libraries like
@actions/githubfor interacting with the GitHub API and@actions/artifactfor uploading and downloading artifacts.Visit the actions/toolkit repository for more.
β¨οΈ Activity: Implement the Dad Jokes Action
Let's create the source files and implement the logic for your action.
Create
src/directory to hold your JavaScript files:Create
src/joke.jsfile to hold the logic for fetching a joke from theicanhazdadjoke.comAPI:The
getJokefunction makes an HTTP GET request to theicanhazdadjoke.comAPI and returns a random dad joke.We export the
getJokefunction so it can be used in other files.Create
src/main.jsthat will be the main entry point for your action:We call the
getJokefunction and follow up withcore.setOutput()to set thejokeoutput of your GitHub Action.Run the action locally to verify it works:
Commit and push:
git add src/ git commit -m "Add Dad Joke action source files" git pushWith the changes pushed to GitHub, Mona will check your work and share the next steps.
github-actions commentedon Feb 4, 2026
Step 2 - Passed β
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Preparing content for step 3! One moment... π€
github-actions commentedon Feb 4, 2026
Step 3: Bundle the Action
Good job! π
Now that you've created the source files for your Dad Jokes GitHub Action and tested it locally, it's time to bundle the action so it can be used in GitHub workflows.
π Theory: Bundling Your Action
When someone uses your action in their workflow, GitHub downloads and executes it as a complete package of code. This means you must include any package dependencies required to run the JavaScript code, such as the
@actions/coreandrequest-promisepackages your action uses.Rather than committing your
node_modulesdirectory (which causes problems with repository size and performance), you can use bundling tools like@vercel/nccto combine your code and dependencies into a singledist/index.jsfile for distribution.β¨οΈ Activity: Build Setup & Bundle
Add a new
buildscript topackage.json(inside the existingscriptsobject):Run the build command. This should create a
dist/directory with a bundledindex.jsfile:(optional) Run the bundled action to verify it works:
Commit and push the changes to the
mainbranch:With the changes pushed to GitHub, Mona will check your work and share the next steps.
github-actions commentedon Feb 4, 2026
Step 3 - Fail β

Some checks failed. Please review the results below and try again.Time to find the bug! π€
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Preparing content for step 2! One moment... π€
github-actions commentedon Feb 4, 2026
Step 2: Create Source Files & Run Locally
Nice! Now that we have the project initialized and dependencies installed, it's time to create the source files for your Dad Jokes GitHub Action.
π Theory: The GitHub Actions Toolkit
The
@actions/corelibrary is the main library from the GitHub Actions Toolkit, a collection of packages for building JavaScript GitHub Actions. It provides essential methods to interact with the GitHub Actions runtime environment, accept action inputs, and produce outputs for other workflow steps.Tip
The GitHub Actions Toolkit includes other useful libraries like
@actions/githubfor interacting with the GitHub API and@actions/artifactfor uploading and downloading artifacts.Visit the actions/toolkit repository for more.
β¨οΈ Activity: Implement the Dad Jokes Action
Let's create the source files and implement the logic for your action.
Create
src/directory to hold your JavaScript files:Create
src/joke.jsfile to hold the logic for fetching a joke from theicanhazdadjoke.comAPI:The
getJokefunction makes an HTTP GET request to theicanhazdadjoke.comAPI and returns a random dad joke.We export the
getJokefunction so it can be used in other files.Create
src/main.jsthat will be the main entry point for your action:We call the
getJokefunction and follow up withcore.setOutput()to set thejokeoutput of your GitHub Action.Run the action locally to verify it works:
Commit and push:
git add src/ git commit -m "Add Dad Joke action source files" git pushWith the changes pushed to GitHub, Mona will check your work and share the next steps.
github-actions commentedon Feb 4, 2026
Step 3 - Passed β
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Preparing content for step 4! One moment... π€
github-actions commentedon Feb 4, 2026
Step 4: Add Action Metadata
Great work! π You've successfully bundled your Dad Jokes GitHub Action into a single file.
Now it's time to create the action metadata file - this special file tells GitHub exactly how to use your action when someone includes it in their workflow!
π Theory: Action Metadata
Every GitHub Action requires a metadata file that defines how the action should be executed and what parameters it accepts.
Metadata File Requirements
The metadata file has specific requirements:
action.ymlCore Metadata Parameters
namedescriptionauthorinputsoutputsrunsbrandingJavaScript Action
runsConfigurationFor JavaScript actions, the
runssection needs:using: Which Node.js version to usemain: The main JavaScript file to runTip
For complete details on all available metadata parameters, optional fields, and advanced configurations, see the official GitHub Actions metadata syntax documentation.
β¨οΈ Activity: Create Metadata File
Create
action.ymlat the repository root (same level aspackage.json).Commit and push the action metadata file to the
mainbranch:git add action.yml git commit -m "Add action metadata file" git pushWith the changes pushed to GitHub, Mona will check your work and share the next steps.
github-actions commentedon Feb 4, 2026
Step 4 - Passed β
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Preparing content for step 5! One moment... π€
github-actions commentedon Feb 4, 2026
Step 5: Create Workflow & Consume Output
Well done! π You've created the Dad Jokes GitHub Action and defined its metadata.
Your action should be ready to use in any GitHub repository now!
β¨οΈ Activity: Author Workflow
Let's see your Dad Jokes action in action by creating a GitHub Actions workflow that uses it!
Create a new GitHub Actions workflow file with the following name
Add the following contents to the workflow file:
This workflow triggers for all new issue comments in the repository.
Because of the
ifconditional, thejokejob only runs if the comment starts with/joke.Commit and push the workflow file to the
mainbranch:git add .github/workflows/joke-action.yml git commit -m "Add workflow to test joke action" git pushWith the workflow pushed to GitHub, Mona will check your work and share the next steps.
github-actions commentedon Feb 4, 2026
Step 5 - Passed β
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Preparing content for step 6! One moment... π€
github-actions commentedon Feb 4, 2026
Step 6: Trigger & Validate
Awesome! π You've created the Dad Jokes GitHub Action, defined its metadata, and authored a workflow to use it.
The only thing left to do is test it out!
β¨οΈ Activity: Try out your action
Create a comment in this issue (or create a new issue) with the text
/jokeMonitor the Actions tab for the
Joke Actionworkflow to complete:Return to the issue and you should see a new comment posted by
github-actions[bot]containing a random dad joke!Mona will post the exercise review once your new Dad Joke workflow completes successfully!
Having trouble? π€·
If the workflow doesn't trigger or fails:
/jokedist/index.jsfile exists and was committednpm run buildand pushed the changesaction.ymlfile is correctly formattedgithub-actions commentedon Feb 4, 2026
Please, follow the steps above.
I'll watch your progress in the background to provide feedback. π§
marnheus commentedon Feb 4, 2026
/joke
marnheus commentedon Feb 4, 2026
/joke
github-actions commentedon Feb 4, 2026
Me and my mates are in a band called Duvet. We're a cover band.
github-actions commentedon Feb 4, 2026
πππ Nice work! Everything is perfect! πππ
Now, let's do a quick review!
github-actions commentedon Feb 4, 2026
Review
Congratulations, you've completed this exercise and learned how to write JavaScript GitHub Actions!
Here's a recap of your accomplishments:
node_moduleswith a.gitignoreconfiguration@actions/corelibrary to handle action outputsdist/index.jsfileaction.yml) defining name, description, outputs, and execution parametersWhat's next?
Check out the other GitHub Skills exercises.
Try using your Dad Jokes action in your other repositories to add some humor to your workflows!
Create your next action using GitHub's template repositories with best practices like tests and linting already built-in:
Actions running pricing
Actions runner pricing
github-actions commentedon Feb 4, 2026
Congratulations @marnheus! You finished the exercise! πππ
We've updated the repository with a couple changes to highlight your success!
Return to the repository home page to see your progress!