0
0
mirror of https://github.com/python/cpython.git synced 2024-11-30 18:51:15 +01:00
cpython/.github/workflows/add-issue-header.yml
dependabot[bot] f21e2f4b12
build(deps): bump actions/github-script from 6 to 7 (#112584)
Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-12-01 11:41:09 +01:00

54 lines
1.6 KiB
YAML

name: Add issue header
# Automatically edits an issue's descriptions with a header,
# one of:
#
# - Bug report
# - Crash report
# - Feature or enhancement
on:
issues:
types:
# Only ever run once
- opened
jobs:
add-header:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v7
with:
# language=JavaScript
script: |
// https://devguide.python.org/triage/labels/#type-labels
const HEADERS = new Map([
['type-bug', 'Bug report'],
['type-crash', 'Crash report'],
['type-feature', 'Feature or enhancement'],
]);
let issue_data = await github.rest.issues.get({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo
}).then(issue => issue.data);
let header = '';
for (const label_data of issue_data.labels) {
const label_name = (typeof label_data === 'string') ? label_data : label_data.name;
if (HEADERS.has(label_name)) {
header = HEADERS.get(label_name);
break;
}
}
if (header !== '') {
console.log(`Setting new header: ${header}`);
await github.rest.issues.update({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `# ${header}\n\n${issue_data.body.replaceAll('\r', '')}`
});
}