
Prerequisites
Before you begin, verify that you have the following:| Requirement | Description |
|---|---|
| Node.js 20.x | JavaScript runtime for your action |
| npm | Package manager to install dependencies |
| GitHub account | Host your repository and run workflows |

1. Project Setup
Create a fresh directory and initialize npm. This scaffolds your package and creates essential files:2. Define Action Metadata
Theaction.yml file tells GitHub how to run your action. Specify inputs and the entrypoint:
The
Be sure to store your
github-token input is usually provided via ${{ secrets.GITHUB_TOKEN }}.Be sure to store your
giphy-api-key in GitHub Secrets to keep it secure.3. Install Dependencies
Install the GitHub Actions Toolkit and Giphy client:| Package | Version | Purpose |
|---|---|---|
| @actions/core | ^1.10.0 | Read inputs, set outputs, and report failures |
| @actions/github | ^5.1.1 | Access GitHub context and helpers |
| @octokit/rest | ^20.0.1 | Interact with the GitHub REST API |
| giphy-api | ^2.0.2 | Fetch random or search-based GIFs from Giphy API |
package.json to confirm these are listed under dependencies.
4. Write the Action Code
Inindex.js, import the necessary modules, fetch a random “thank you” GIF, and post it as a comment on the pull request:

5. Bundle with ncc
To avoid committingnode_modules, bundle your code and dependencies into a single file using Vercel ncc:
ncc produces dist/index.js with your action logic and all dependencies. This simplifies deployment.6. Ignore Unnecessary Files
Add a.gitignore to keep your repository clean:
7. Publish to GitHub
Initialize and push your project:

You’ve now successfully created, bundled, and published a JavaScript GitHub Action. Next, tag a release and submit it to the GitHub Marketplace so others can use it!