ci/github-script/labels: auto close package request issues (#434730)

authored by Wolfgang Walther and committed by GitHub 036a9335 af51f6b6

+49 -7
+2 -7
.github/ISSUE_TEMPLATE/10_package_request.yml
··· 16 16 </a> 17 17 </p> 18 18 19 - Thank you for your interest in packaging new software in Nixpkgs. 20 - Unfortunately, to mitigate the unsustainable growth of unmaintained packages, **Nixpkgs is no longer accepting package requests** via Issues. 19 + Thank you for your interest in packaging new software in Nixpkgs. Unfortunately, to mitigate the unsustainable growth of unmaintained packages, **Nixpkgs is no longer accepting package requests** via Issues. 21 20 22 - As a [volunteer community][community], we are always open to new contributors. 23 - If you wish to see this package in Nixpkgs, **we encourage you to [contribute] it yourself, via a Pull Request**. 24 - Anyone can [become a package maintainer][maintainers]! 25 - You can find language-specific packaging information in the [Nixpkgs Manual][nixpkgs]. 26 - Should you need any help, please reach out to the community on [Matrix] or [Discourse]. 21 + As a [volunteer community][community], we are always open to new contributors. If you wish to see this package in Nixpkgs, **we encourage you to [contribute] it yourself**, via a Pull Request. Anyone can [become a package maintainer][maintainers]! You can find language-specific packaging information in the [Nixpkgs Manual][nixpkgs]. Should you need any help, please reach out to the community on [Matrix] or [Discourse]. 27 22 28 23 [community]: https://nixos.org/community 29 24 [contribute]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#quick-start-to-adding-a-package
+47
ci/github-script/labels.js
··· 171 171 return prLabels 172 172 } 173 173 174 + // Returns true if the issue was closed. In this case, the labeling does not need to 175 + // continue for this issue. Returns false if no action was taken. 176 + async function handleAutoClose(item) { 177 + const issue_number = item.number 178 + 179 + if (item.labels.some(({ name }) => name === '0.kind: packaging request')) { 180 + const body = [ 181 + 'Thank you for your interest in packaging new software in Nixpkgs. Unfortunately, to mitigate the unsustainable growth of unmaintained packages, **Nixpkgs is no longer accepting package requests** via Issues.', 182 + '', 183 + 'As a [volunteer community][community], we are always open to new contributors. If you wish to see this package in Nixpkgs, **we encourage you to [contribute] it yourself**, via a Pull Request. Anyone can [become a package maintainer][maintainers]! You can find language-specific packaging information in the [Nixpkgs Manual][nixpkgs]. Should you need any help, please reach out to the community on [Matrix] or [Discourse].', 184 + '', 185 + '[community]: https://nixos.org/community', 186 + '[contribute]: https://github.com/NixOS/nixpkgs/blob/master/pkgs/README.md#quick-start-to-adding-a-package', 187 + '[maintainers]: https://github.com/NixOS/nixpkgs/blob/master/maintainers/README.md', 188 + '[nixpkgs]: https://nixos.org/manual/nixpkgs/unstable/', 189 + '[Matrix]: https://matrix.to/#/#dev:nixos.org', 190 + '[Discourse]: https://discourse.nixos.org/c/dev/14', 191 + ].join('\n') 192 + 193 + core.info(`Issue #${item.number}: auto-closed`) 194 + 195 + if (!dry) { 196 + await github.rest.issues.createComment({ 197 + ...context.repo, 198 + issue_number, 199 + body, 200 + }) 201 + 202 + await github.rest.issues.update({ 203 + ...context.repo, 204 + issue_number, 205 + state: 'closed', 206 + state_reason: 'not_planned', 207 + }) 208 + } 209 + 210 + return true 211 + } 212 + return false 213 + } 214 + 174 215 async function handle({ item, stats }) { 175 216 try { 176 217 const log = (k, v, skip) => { ··· 190 231 Object.assign(itemLabels, await handlePullRequest({ item, stats })) 191 232 } else { 192 233 stats.issues++ 234 + if (item.labels.some(({ name }) => name === '4.workflow: auto-close')) { 235 + // If this returns true, the issue was closed. In this case we return, to not 236 + // label the issue anymore. Most importantly this avoids unlabeling stale issues 237 + // which are closed via auto-close. 238 + if (await handleAutoClose(item)) return 239 + } 193 240 } 194 241 195 242 const latest_event_at = new Date(