diff options
author | Adam Turner <9087854+AA-Turner@users.noreply.github.com> | 2023-08-17 15:37:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-08-17 15:37:07 (GMT) |
commit | 4cb08188e8f0faaec303e268e12aa1d6f54017f7 (patch) | |
tree | 6f2fc7e24d9d9c50b09e40a340a03340bb825d7c /.github | |
parent | 8a19f225b948db1eebe1d9fc71a486258841f578 (diff) | |
download | cpython-4cb08188e8f0faaec303e268e12aa1d6f54017f7.zip cpython-4cb08188e8f0faaec303e268e12aa1d6f54017f7.tar.gz cpython-4cb08188e8f0faaec303e268e12aa1d6f54017f7.tar.bz2 |
Add workflow for automatic issue headers (#108054)
We don't get the "Bug report" and "Feature or enhancement" titles anymore, with the new issue forms. This brings them back!
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/add-issue-header.yml | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/.github/workflows/add-issue-header.yml b/.github/workflows/add-issue-header.yml new file mode 100644 index 0000000..1ef9178 --- /dev/null +++ b/.github/workflows/add-issue-header.yml @@ -0,0 +1,53 @@ +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@v6 + 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', '')}` + }); + } |