{"id":22727504,"url":"https://github.com/pagopa-archive/danger-plugin","last_synced_at":"2025-08-08T07:30:58.359Z","repository":{"id":37822778,"uuid":"496614712","full_name":"pagopa/danger-plugin","owner":"pagopa","description":"This module provides custom rules over Danger CI automation.","archived":false,"fork":false,"pushed_at":"2023-01-08T19:35:46.000Z","size":271,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-11-28T17:28:58.726Z","etag":null,"topics":["danger","danger-js","danger-plugin","jira","typescript"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@pagopa/danger-plugin","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"eupl-1.2","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pagopa.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-26T12:37:49.000Z","updated_at":"2022-07-27T00:49:08.000Z","dependencies_parsed_at":"2023-02-08T07:16:24.082Z","dependency_job_id":null,"html_url":"https://github.com/pagopa/danger-plugin","commit_stats":null,"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagopa%2Fdanger-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagopa%2Fdanger-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagopa%2Fdanger-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pagopa%2Fdanger-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pagopa","download_url":"https://codeload.github.com/pagopa/danger-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229097324,"owners_count":18019735,"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":["danger","danger-js","danger-plugin","jira","typescript"],"created_at":"2024-12-10T17:12:22.611Z","updated_at":"2025-08-08T07:30:52.872Z","avatar_url":"https://github.com/pagopa.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Custom DangerJS rules plugin\n\n![npm](https://img.shields.io/npm/v/@pagopa/danger-plugin?color=green\u0026label=%40pagopa%2Fdanger-plugin\u0026logo=npm)\n![Azure DevOps builds](https://img.shields.io/azure-devops/build/pagopaspa/a1eb6f06-1593-4a60-b2aa-9ff49c60340d/672?label=Code%20review)\n![Azure DevOps builds](https://img.shields.io/azure-devops/build/pagopaspa/a1eb6f06-1593-4a60-b2aa-9ff49c60340d/671?label=Deploy)\n![npm type definitions](https://img.shields.io/npm/types/@pagopa/danger-plugin)\n\nThis module provides custom rules over [Danger](https://danger.systems/js/) CI automation.\n\n## Features\n\n- Cross-link with [Jira](https://pagopa.atlassian.net/jira) stories, based on PR title\n- Warn when a PR has no description\n- Update the PR title with the right changelog configuration and scope\n- Update the generated changelog, adding the link to the related Jira ticket\n- Warn if `npm`-related files are added (as we use `yarn`)\n\n## Usage\n\nTo use you must already have `danger-js` set up in your repo.\nIf you haven't configured it yet:\n\n```sh\nyarn add danger --dev\n```\n\n### Install\n\n```sh\nyarn add @pagopa/danger-plugin --dev\n```\n\n### At a glance\n\nCreate a new file `Dangerfile.ts` in your root working dir. It is **mandatory** to define a `Configuration` that allows you to make a mapping between a ticket projectid or ticket tag with a scope that is mainly a string that allows you to better describe it.\n\n```js\n// Dangerfile.ts\nimport customRules from \"@pagopa/danger-plugin\";\nimport { Configuration } from \"@pagopa/danger-plugin/dist/types\";\n\nconst configuration: Configuration = {\n  projectToScope: {\n    IAC: \"Bonus Pagamenti Digitali\",\n    IOACGN: \"Carta Giovani Nazionale\",\n    IAGP: \"EU Covid Certificate\",\n  },\n  tagToScope: {\n    android: \"Android\",\n    ios: \"iOS\",\n    messages: \"Messages\",\n    payments: \"Payments\",\n    services: \"Services\",\n  },\n\n  // minimum length of the PR description below which a warning is generated\n  minLenPrDescription: 10,\n\n  // To add a label to the PR containing the name of the project linked to the task on Jira.\n  updateLabel: true,\n\n  // To change the title of the PR according to whether the task on Jira is a feat (Story) / fix (Bug) / chore (Sub-task) / epic.\n  updateTitle: false,\n};\n\ncustomRules(configuration);\n```\n\nLook at the [Dangerfile.ts](https://github.com/pagopa/danger-plugin/blob/master/Dangerfile.ts) file to better understand how to structure it.\n\n### Creating a GitHub bot account for Danger\n\nIn order to get the most out of Danger, we recommend giving it the ability to post comments in your Pull Requests. This is a regular GitHub account, but depending on whether you are working on a private or public project, you will want to give different levels of access to this bot.\n\n### Environment variables\n\nA token related to github bot account is required to enable the reading of the repo and comment the PR on github to be set in the environment variable:\n\n```\nDANGER_GITHUB_API_TOKEN=\".....\"\n```\n\nFurthermore, to access the Jira API it is necessary to create a token relating to a service account and set the following environment variables:\n\n```\nJIRA_USERNAME=account@pagopa.it\nJIRA_PASSWORD=token...\n```\n\n### DevOps pipeline\n\nexample of a pipeline stage for the code review\n\n```yml\nstages:\n  - stage: Static_analysis\n    dependsOn: []\n    jobs:\n      - job: danger\n        condition: and(\n          succeeded(),\n          and(\n          eq(variables['Build.Reason'], 'PullRequest'),\n          ne(variables['DANGER_GITHUB_API_TOKEN'], 'skip')\n          )\n          )\n        steps:\n          - template: templates/node-job-setup/template.yaml@pagopaCommons\n          - bash: |\n              yarn danger ci\n            env:\n              DANGER_GITHUB_API_TOKEN: \"$(DANGER_GITHUB_API_TOKEN)\"\n              JIRA_USERNAME: \"$(JIRA_USERNAME)\"\n              JIRA_PASSWORD: \"$(JIRA_PASSWORD)\"\n            displayName: \"Danger CI\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpagopa-archive%2Fdanger-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpagopa-archive%2Fdanger-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpagopa-archive%2Fdanger-plugin/lists"}