{"id":20176358,"url":"https://github.com/emibcn/github-badge-action","last_synced_at":"2025-04-10T04:07:45.742Z","repository":{"id":37095343,"uuid":"369903914","full_name":"emibcn/github-badge-action","owner":"emibcn","description":"JavaScript package to create a badge using GitHub Actions inputs \u0026 outputs, and save it into a file","archived":false,"fork":false,"pushed_at":"2025-03-18T06:56:11.000Z","size":2644,"stargazers_count":1,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-10T04:07:39.350Z","etag":null,"topics":["badge","badge-action","badge-generator","github","github-action","github-actions","hacktoberfest","icon","javascipt","javascript-library","library","npm-package","svg-badge"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/emibcn.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}},"created_at":"2021-05-22T20:53:56.000Z","updated_at":"2025-03-18T06:56:12.000Z","dependencies_parsed_at":"2024-02-07T09:25:58.130Z","dependency_job_id":"afb5a62a-d338-4037-be8c-94f17812759f","html_url":"https://github.com/emibcn/github-badge-action","commit_stats":{"total_commits":324,"total_committers":6,"mean_commits":54.0,"dds":"0.12962962962962965","last_synced_commit":"60e0ba423abdaa0f8ad614d6c3865b422645d5bc"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emibcn%2Fgithub-badge-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emibcn%2Fgithub-badge-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emibcn%2Fgithub-badge-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emibcn%2Fgithub-badge-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emibcn","download_url":"https://codeload.github.com/emibcn/github-badge-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154986,"owners_count":21056543,"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":["badge","badge-action","badge-generator","github","github-action","github-actions","hacktoberfest","icon","javascipt","javascript-library","library","npm-package","svg-badge"],"created_at":"2024-11-14T02:08:45.851Z","updated_at":"2025-04-10T04:07:45.723Z","avatar_url":"https://github.com/emibcn.png","language":"JavaScript","readme":"[![Test](https://github.com/emibcn/github-badge-action/actions/workflows/test.js.yml/badge.svg)](https://github.com/emibcn/github-badge-action/actions/workflows/test.js.yml)\n![Coverage](https://raw.githubusercontent.com/emibcn/github-badge-action/badges/main/test-coverage.svg)\n![Test generated badge](https://raw.githubusercontent.com/emibcn/github-badge-action/badges/main/test-badge.svg)\n\n# GitHub Badge action\n\nThis module generates a SVG badge using GitHub Actions inputs and outputs. The badge is generated using the NPM package [gradient-badge](https://github.com/bokub/gradient-badge) and echoed as a GitHub Action output, and saved into a file if a `path` is given. This is the core of the GitHub Action [Badge action](https://github.com/marketplace/actions/badge-action).\n\n## Install\nWith `npm`:\n```shell\nnpm install github-badge-action\n```\n\nWith `yarn`:\n```shell\nyarn add github-badge-action\n```\n\n## Usage\n\n```javascript\nconst { createBadgeFromInputs } = require('github-badge-action');\ncreateBadgeFromInputs();\n```\n\n## Inputs\n\nInputs are read from action's inputs using `core.input`, fixed and passed directly to `gradient-badge`.\n\n### Change input names\nThe input names are taken from `createBadgeFromInputs`'s `inputMap` argument, which has this deafults:\n```javascript\nconst defaultInputMap = {\n  label: 'label',\n  labelColor: 'label-color',\n  status: 'status',\n  gradient: 'color',\n  style: 'style',\n  icon: 'icon',\n  iconWidth: 'icon-width',\n  scale: 'scale',\n  path: 'path',\n};\n```\n\nYou can import it and modify just some of the options names:\n```javascript\nconst {\n  createBadgeFromInputs,\n  defaultInputMap\n} = require('github-badge-action');\n\ncreateBadgeFromInputs({\n  inputMap: {\n    ...defaultInputMap,\n    gradient: 'gradient',\n  },\n});\n```\n\n### Change input fixes\nOnce the inputs are read, some **fixes are applied**. The default ones are:\n```javascript\nconst defaultInputFixes = {\n  // Ensure string\n  status: (status) =\u003e `${status}`,\n\n  // Ensure null if empty\n  icon: (icon) =\u003e icon?.length ? icon : null,\n\n  // Color gradient as Array\n  gradient: (gradient) =\u003e gradient\n      .split(',')\n      // Clean spaces\n      .map((color) =\u003e color.trim(' ')),\n};\n```\n\nYou can also change the fixes applied to the inputs, or add more using `inputFixes` option:\n```javascript\nconst {\n  createBadgeFromInputs,\n  defaultInputFixes\n} = require('github-badge-action');\n\ncreateBadgeFromInputs({\n  inputFixes: {\n    ...defaultInputFixes,\n    // Color gradient as Array, split with a pipe '|' instead of a comma ','\n    gradient: ({ gradient }) =\u003e gradient\n        .split('|')\n        // Clean spaces\n        .map((color) =\u003e color.trim(' ')),\n  },\n});\n```\n\n### Available options\n#### `label`\n\n**Required** The left label of the badge, usually static.\n\n#### `label-color`\n\n**Required** Hex or named color for the label. Default: `555`\n\n#### `status`\n\n**Required** The right status as the badge, usually based on results.\n\n#### `color`\n\n**Required** An array (comma separated) with hex or named colors of the badge value background. More than one creates gradient background. Default: `blue`.\n\n#### `style`\n\n**Required** Badge style: flat or classic. Default: `classic`\n\n#### `icon`\n\nUse icon.\n\n#### `icon-width`\n\nSet this if icon is not square. Default: `13`\n\n#### `scale`\n\nSet badge scale. Default: `1`\n\n#### `path`\n\nThe file path to store the badge image file. Only output to `badge` action output if not defined.\n\n## Outputs\n\n### `badge`\nOnce the badge is generated, the SVG contents are written to an action output (by default). The name of the output can be modified using `outputName` option:\n```javascript\ncreateBadgeFromInputs({\n  outputName: 'badge-svg-custom'\n});\n```\n\nIf the option is `null` or empty, **output will not be written**. The default option name is `badge`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femibcn%2Fgithub-badge-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femibcn%2Fgithub-badge-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femibcn%2Fgithub-badge-action/lists"}