@kcws/actkits
v0.1.9
Published
Shared GitHub Actions Toolkits
Maintainers
Readme
@kcws/actkits
Shared GitHub Actions toolkit utilities for context detection, typed input parsing, structured logging, and workflow outputs.
Installation
pnpm add @kcws/actkitsWhat is included
@kcws/actkits/context- Read GitHub Actions runtime context from environment variables
- Check common workflow predicates (push, pull request, release, tag, branch)
- Build links to repository and run pages
@kcws/actkits/input- Parse action inputs with Zod schemas
- Resolve values from
process.envand@actions/coreinputs - Includes parsers such as
zBoolean,zNumber,zJsonString, andzYamlFile
@kcws/actkits/logging- Namespaced logger wrapper around
@actions/core printfstyle formatting and grouped logs
- Namespaced logger wrapper around
@kcws/actkits/output- Type-friendly
setOutputandsetOutputshelpers
- Type-friendly
Usage
Parse typed inputs
import { parseInput, z, zBoolean, zNumber } from "@kcws/actkits/input";
const schema = z.object({
dryRun: zBoolean().default(false),
retries: zNumber().int().min(0).default(0),
token: z.string().min(1),
});
const input = parseInput(schema);
// input is strongly typed from the schemaWork with GitHub context
import { getContext, isPullRequestEvent, getRunUrl } from "@kcws/actkits/context";
const context = getContext();
if (isPullRequestEvent(context)) {
const runUrl = getRunUrl(context);
console.log("Running on pull request", runUrl);
}Log with namespaces
import { createLogger } from "@kcws/actkits/logging";
const logger = createLogger("release", "publish");
logger.info("Starting publish for %s", "my-package");
logger.notice("Version %s is ready", "1.2.3");Set workflow outputs
import { setOutput, setOutputs } from "@kcws/actkits/output";
setOutput("version", "1.2.3");
setOutputs({
published: true,
artifactCount: 2,
metadata: { channel: "stable" },
});