{"id":50643399,"url":"https://github.com/threeal/ghakit","last_synced_at":"2026-06-07T10:31:13.639Z","repository":{"id":252096192,"uuid":"839409781","full_name":"threeal/ghakit","owner":"threeal","description":"A toolkit for building GitHub Actions with no runtime dependencies","archived":false,"fork":false,"pushed_at":"2026-05-31T06:55:01.000Z","size":984,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-05-31T08:15:57.912Z","etag":null,"topics":["github","github-actions","javascript","node","nodejs","toolkit","typescript"],"latest_commit_sha":null,"homepage":"https://threeal.github.io/ghakit/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/threeal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-08-07T14:49:55.000Z","updated_at":"2026-05-31T06:55:04.000Z","dependencies_parsed_at":"2024-08-07T18:11:26.489Z","dependency_job_id":"4041a284-3d87-4d4c-b2fe-39147d5670e3","html_url":"https://github.com/threeal/ghakit","commit_stats":{"total_commits":106,"total_committers":2,"mean_commits":53.0,"dds":0.4811320754716981,"last_synced_commit":"a2ddcd994701652d33d7246839b918cb245f4533"},"previous_names":["threeal/gha-utils","threeal/actkit","threeal/ghakit"],"tags_count":6,"template":false,"template_full_name":"threeal/nodejs-starter","purl":"pkg:github/threeal/ghakit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fghakit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fghakit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fghakit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fghakit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threeal","download_url":"https://codeload.github.com/threeal/ghakit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fghakit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34018404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-07T02:00:07.652Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["github","github-actions","javascript","node","nodejs","toolkit","typescript"],"created_at":"2026-06-07T10:31:12.868Z","updated_at":"2026-06-07T10:31:13.633Z","avatar_url":"https://github.com/threeal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GhaKit\n\nA toolkit for building [GitHub Actions](https://github.com/features/actions). Wraps GitHub Actions' file-based and stdout-based workflow APIs into typed, promise-friendly functions, with no runtime dependencies.\n\n## Installation\n\n```sh\nnpm install ghakit\n```\n\n## Modules\n\n| Import                       | Purpose                                                             |\n| ---------------------------- | ------------------------------------------------------------------- |\n| [`ghakit/io`](#ghakitio)     | Read inputs; write outputs, state, env vars, and system paths       |\n| [`ghakit/log`](#ghakitlog)   | Log messages, mask secrets, group output, control workflow commands |\n| [`ghakit/exec`](#ghakitexec) | Spawn child processes with stdout/stderr capture or suppression     |\n| [`ghakit/vars`](#ghakitvars) | Typed getters for all default GitHub Actions variables              |\n\nFull API reference: [threeal.github.io/ghakit](https://threeal.github.io/ghakit)\n\n---\n\n## `ghakit/io`\n\n### Reading inputs\n\n```ts\nimport { getInput } from \"ghakit/io\";\n\nconst token = getInput(\"token\"); // returns \"\" if the input is not set\n```\n\n### Writing outputs\n\n```ts\nimport { setOutput } from \"ghakit/io\";\n\nawait setOutput(\"result\", \"success\");\n```\n\nA synchronous variant [`setOutputSync`](https://threeal.github.io/ghakit/functions/io.setOutputSync.html) is also available.\n\n### State (pre/post steps)\n\nState persists across the pre, main, and post steps of the same action.\n\n```ts\nimport { getState, setState } from \"ghakit/io\";\n\n// In the main step:\nawait setState(\"cache-key\", key);\n\n// In the post step:\nconst cachedKey = getState(\"cache-key\");\n```\n\nA synchronous variant [`setStateSync`](https://threeal.github.io/ghakit/functions/io.setStateSync.html) is also available.\n\n### Environment variables\n\nSets the variable in the current process and exports it to subsequent steps.\n\n```ts\nimport { setEnv } from \"ghakit/io\";\n\nawait setEnv(\"MY_VAR\", \"value\");\n```\n\nA synchronous variant [`setEnvSync`](https://threeal.github.io/ghakit/functions/io.setEnvSync.html) is also available.\n\n### System path\n\nPrepends the path to `PATH` in the current process and exports it to subsequent steps.\n\n```ts\nimport { addPath } from \"ghakit/io\";\n\nawait addPath(\"/usr/local/custom/bin\");\n```\n\nA synchronous variant [`addPathSync`](https://threeal.github.io/ghakit/functions/io.addPathSync.html) is also available.\n\n---\n\n## `ghakit/log`\n\n### Message levels\n\n```ts\nimport { logDebug, logError, logInfo, logNotice, logWarning } from \"ghakit/log\";\n\nlogInfo(\"starting task\");\nlogDebug(\"verbose detail\"); // only shown when debug logging is enabled\nlogNotice(\"something worth noting\");\nlogWarning(\"non-fatal issue\");\nlogError(\"something failed\");\n```\n\n`logError` accepts `unknown`, matching the type of a caught exception, so it can be passed directly in a `catch` block:\n\n```ts\ntry {\n  // ...\n} catch (err) {\n  logError(err);\n}\n```\n\n`logNotice`, `logWarning`, and `logError` accept an optional [`AnnotationOptions`](https://threeal.github.io/ghakit/interfaces/log.AnnotationOptions.html) to pin the message to a file location:\n\n```ts\nlogError(\"type mismatch\", { file: \"src/index.ts\", line: 42, col: 5 });\nlogWarning(\"deprecated call\", {\n  title: \"Deprecation Warning\",\n  file: \"src/index.ts\",\n  line: 10,\n});\nlogNotice(\"review this\", { file: \"src/index.ts\", line: 1 });\n```\n\n### Logging commands\n\nOutputs a `[command]` line to mark shell command execution in the workflow log.\n\n```ts\nimport { logCommand } from \"ghakit/log\";\n\nlogCommand(\"git\", \"fetch\", \"--all\"); // renders as [command]git fetch --all\n```\n\n### Masking secrets\n\nAny subsequent occurrence of the masked value in the workflow logs is replaced with `***`.\n\n```ts\nimport { addLogMask } from \"ghakit/log\";\n\naddLogMask(process.env.MY_SECRET ?? \"\");\n```\n\n### Log groups\n\nAll messages logged between `beginLogGroup` and `endLogGroup` are nested inside a collapsible section.\n\n```ts\nimport { beginLogGroup, endLogGroup, logInfo } from \"ghakit/log\";\n\nbeginLogGroup(\"build output\");\nlogInfo(\"compiling...\");\nendLogGroup();\n```\n\n### Stopping workflow command processing\n\nOutput between `stopCommands` and `resumeCommands` is not interpreted as workflow commands.\n\n```ts\nimport { randomUUID } from \"node:crypto\";\nimport { resumeCommands, stopCommands } from \"ghakit/log\";\n\nconst token = randomUUID();\nstopCommands(token);\n// Lines here are printed verbatim\nresumeCommands(token);\n```\n\n---\n\n## `ghakit/exec`\n\nRuns a command as a child process. By default, passes stdout and stderr to the current process. Rejects with an `Error` if the process fails to spawn, exits with a non-zero code, or is killed by a signal.\n\n```ts\nimport { exec } from \"ghakit/exec\";\n\nawait exec(\"git\", [\"fetch\", \"--all\"]);\n```\n\nSet `stdout` or `stderr` to `\"silent\"` to suppress that stream:\n\n```ts\nawait exec(\"git\", [\"fetch\", \"--all\"], { stderr: \"silent\" });\n```\n\nSet either to `\"capture\"` to collect and return it as a string:\n\n```ts\nconst { stdout } = await exec(\"git\", [\"rev-parse\", \"HEAD\"], {\n  stdout: \"capture\",\n});\n```\n\nBoth streams can also be captured at once:\n\n```ts\nconst { stdout, stderr } = await exec(\"git\", [\"rev-parse\", \"HEAD\"], {\n  stdout: \"capture\",\n  stderr: \"capture\",\n});\n```\n\n---\n\n## `ghakit/vars`\n\nTyped getters for every [default GitHub Actions variable](https://docs.github.com/en/actions/reference/workflows-and-actions/variables). Boolean variables return `boolean`, numeric count/day variables return `number`, context-specific variables (only set in certain events or action types) return `string | undefined`, and all others return `string`.\n\n```ts\nimport {\n  getCI,\n  getGitHubEventName,\n  getGitHubRefName,\n  getGitHubRepository,\n  getGitHubRunAttempt,\n  getGitHubRunId,\n  getGitHubRunNumber,\n  getGitHubSha,\n  getRunnerArch,\n  getRunnerDebug,\n  getRunnerOs,\n} from \"ghakit/vars\";\n\nconst repo = getGitHubRepository(); // \"owner/repo\"\nconst sha = getGitHubSha(); // triggering commit SHA\nconst ref = getGitHubRefName(); // e.g. \"main\"\nconst event = getGitHubEventName(); // e.g. \"push\"\nconst isCI = getCI(); // boolean\nconst runId = getGitHubRunId(); // e.g. \"1234567890\"\nconst runNumber = getGitHubRunNumber(); // number\nconst runAttempt = getGitHubRunAttempt(); // number\nconst os = getRunnerOs(); // \"Linux\", \"Windows\", or \"macOS\"\nconst arch = getRunnerArch(); // \"X64\", \"ARM64\", etc.\nconst isDebug = getRunnerDebug(); // boolean\n```\n\nFor the full list of available getters, see the [API reference](https://threeal.github.io/ghakit/modules/vars.html).\n\n---\n\n## License\n\nThis project is licensed under the [MIT License](./LICENSE).\n\nCopyright © 2024–2026 [Alfi Maulana](https://github.com/threeal)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeal%2Fghakit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreeal%2Fghakit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeal%2Fghakit/lists"}