{"id":16962485,"url":"https://github.com/threeal/gha-utils","last_synced_at":"2025-04-11T21:31:18.966Z","repository":{"id":252096192,"uuid":"839409781","full_name":"threeal/gha-utils","owner":"threeal","description":"A minimalistic utility package for developing GitHub Actions.","archived":false,"fork":false,"pushed_at":"2025-04-11T03:15:53.000Z","size":888,"stargazers_count":2,"open_issues_count":5,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-11T04:22:57.781Z","etag":null,"topics":["github","github-actions","javascript","node","nodejs","typescript","utility"],"latest_commit_sha":null,"homepage":"https://threeal.github.io/gha-utils/","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}},"created_at":"2024-08-07T14:49:55.000Z","updated_at":"2025-04-11T03:14:35.000Z","dependencies_parsed_at":"2024-08-07T18:11:26.489Z","dependency_job_id":"a11ba149-424c-4882-b348-abbe3b0213f9","html_url":"https://github.com/threeal/gha-utils","commit_stats":{"total_commits":106,"total_committers":2,"mean_commits":53.0,"dds":0.4811320754716981,"last_synced_commit":"a2ddcd994701652d33d7246839b918cb245f4533"},"previous_names":["threeal/gha-utils"],"tags_count":5,"template":false,"template_full_name":"threeal/nodejs-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fgha-utils","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fgha-utils/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fgha-utils/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/threeal%2Fgha-utils/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/threeal","download_url":"https://codeload.github.com/threeal/gha-utils/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248482932,"owners_count":21111402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","typescript","utility"],"created_at":"2024-10-13T23:06:53.668Z","updated_at":"2025-04-11T21:31:18.952Z","avatar_url":"https://github.com/threeal.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitHub Actions Utilities\n\nA minimalistic utility package for developing [GitHub Actions](https://github.com/features/actions).\n\n## Key Features\n\n- ES Module support\n- Getting inputs and setting outputs\n- Getting and setting states\n- Setting environment variables and appending system paths\n- Logging various kinds of messages\n\n## Installation\n\nThis project is available as an [npm](https://www.npmjs.com/) package under the name [gha-utils](https://www.npmjs.com/package/gha-utils):\n\n```sh\nnpm install gha-utils\n```\n\n## Usage Guide\n\n### Getting Inputs and Setting Outputs\n\nGitHub Actions inputs can be retrieved using the [`getInput`](https://threeal.github.io/gha-utils/functions/getInput.html) function, which returns a trimmed string or an empty string if the input is not specified. GitHub Actions outputs can be set using the [`setOutput`](https://threeal.github.io/gha-utils/functions/setOutput.html) or [`setOutputSync`](https://threeal.github.io/gha-utils/functions/setOutputSync.html) functions:\n\n```ts\nconst input = getInput(\"input-name\");\n\nawait setOutput(\"output-name\", \"a value\");\nsetOutputSync(\"another-output-name\", \"another value\");\n```\n\n### Getting and Setting States\n\nGitHub Actions states are useful for passing data between the pre, main, and post steps of the same GitHub Action. States can be set using the [`setState`](https://threeal.github.io/gha-utils/functions/setState.html) or [`setStateSync`](https://threeal.github.io/gha-utils/functions/setStateSync.html) functions:\n\n```ts\nawait setState(\"state-name\", \"a value\");\nsetStateSync(\"another-state-name\", \"another value\");\n```\n\nThey can then be retrieved in the current or other steps using the [`getState`](https://threeal.github.io/gha-utils/functions/getState.html) function:\n\n```ts\nconst state = getState(\"state-name\");\n```\n\n### Setting Environment Variables\n\nEnvironment variables in GitHub Actions can be set using the [`setEnv`](https://threeal.github.io/gha-utils/functions/setEnv.html) or [`setEnvSync`](https://threeal.github.io/gha-utils/functions/setEnvSync.html) functions, which sets the environment variables in the current step and exports them to the next steps:\n\n```ts\nawait setEnv(\"AN_ENV\", \"a value\");\nsetEnvSync(\"ANOTHER_ENV\", \"another value\");\n```\n\n### Adding System Paths\n\nSystem paths in the GitHub Actions environment can be added using the [`addPath`](https://threeal.github.io/gha-utils/functions/addPath.html) or [`addPathSync`](https://threeal.github.io/gha-utils/functions/addPathSync.html) functions, which prepends the given path to the system path. These functions are useful if an action is adding a new executable located in a custom path:\n\n```ts\nawait addPath(\"path/to/an/executable\");\naddPathSync(\"path/to/another/executable\");\n```\n\n### Logging Messages\n\nThere are various ways to log messages in GitHub Actions, including [`logInfo`](https://threeal.github.io/gha-utils/functions/logInfo.html) for logging an informational message, [`logDebug`](https://threeal.github.io/gha-utils/functions/logDebug.html) for logging a debug message, [`logWarning`](https://threeal.github.io/gha-utils/functions/logWarning.html) for logging a warning message, [`logError`](https://threeal.github.io/gha-utils/functions/logError.html) for logging an error message, and [`logCommand`](https://threeal.github.io/gha-utils/functions/logCommand.html) for logging a command line message:\n\n```ts\ntry {\n  logInfo(\"an information\");\n  logDebug(\"a debug\");\n  logWarning(\"a warning\");\n  logCommand(\"command\", \"arg0\", \"arg1\", \"arg2\");\n} catch (err) {\n  logError(err);\n}\n```\n\n### Grouping Logs\n\nLogs can be grouped using the [`beginLogGroup`](https://threeal.github.io/gha-utils/functions/beginLogGroup.html) and [`endLogGroup`](https://threeal.github.io/gha-utils/functions/endLogGroup.html) functions. All messages logged between these functions will be displayed as a group within a collapsible section:\n\n```ts\nbeginLogGroup(\"a log group\");\nlogInfo(\"this message is inside a group\");\nendLogGroup();\n\nlogInfo(\"this message is outside a group\");\n```\n\n## License\n\nThis project is licensed under the terms of the [MIT License](./LICENSE).\n\nCopyright © 2024-2025 [Alfi Maulana](https://github.com/threeal)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeal%2Fgha-utils","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthreeal%2Fgha-utils","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthreeal%2Fgha-utils/lists"}