A minimal template for building a JavaScript GitHub Action.
Create a new repository from this template on GitHub using this link.
Or clone it locally and point it at your own remote.
Install pnpm, then install dependencies:
pnpm installInstall Lefthook, then register the pre-commit hooks:
lefthook installUpdate the action's name, description, branding, and inputs/outputs to match what your action does.
This is the action's entry point. Replace the example logic with your own. Use gha-utils to read inputs, write outputs, and log errors:
import { getInput, logError, setOutput } from "gha-utils";
try {
const input = getInput("my-input");
// ... your action logic ...
setOutput("my-output", result);
} catch (err) {
logError(err);
process.exitCode = 1;
}The template ships with the Unlicense (public domain). Replace it with the license you want, or leave it as-is.
Write your code in src/. When you're ready, just commit — the pre-commit hook will automatically:
- Install dependencies
- Format code (Prettier)
- Fix lint issues (ESLint)
- Type-check (TypeScript)
- Build the bundle (
dist/main.bundle.mjs)
If the hook reports errors, fix them and commit again. The dist/ folder must be committed — it's what GitHub Actions runs.
Add test files alongside source files as *.test.ts. Run all tests with:
pnpm test100% code coverage is enforced. Tests use Vitest.
.github/workflows/ci.yaml runs two jobs on every push and pull request:
- check — validates the pre-commit hook and runs tests
- test — runs the real action on Ubuntu, macOS, and Windows
Update the test job to exercise your action's actual inputs and verify its outputs.
Tag a release on GitHub:
git tag v1.0.0
git push origin v1.0.0Then create a GitHub Release from that tag. To make the action discoverable, publish it to the GitHub Marketplace from the release page.