mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-19 13:36:48 +00:00
1a4df59bf3
No job had timeout-minutes, so a hung step held a runner for GitHub's six-hour default. Test and housekeeping jobs stop after 45 minutes, the image builds after two hours.
95 lines
3.4 KiB
YAML
95 lines
3.4 KiB
YAML
name: Flag issues with bad titles
|
|
|
|
on:
|
|
issues:
|
|
types: [opened]
|
|
|
|
permissions:
|
|
issues: write
|
|
|
|
jobs:
|
|
check-title:
|
|
if: github.repository == 'liketrek/TREK'
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 45
|
|
steps:
|
|
- name: Flag or redirect issue
|
|
uses: actions/github-script@v7
|
|
with:
|
|
script: |
|
|
const title = context.payload.issue.title.trim();
|
|
const titleLower = title.toLowerCase();
|
|
|
|
const badTitles = [
|
|
"[bug]", "bug report", "bug", "issue",
|
|
"help", "question", "test", "...", "untitled"
|
|
];
|
|
|
|
const featureRequestTitles = [
|
|
"feature request", "[feature]", "[feature request]", "[enhancement]"
|
|
];
|
|
|
|
if (badTitles.includes(titleLower)) {
|
|
// Ensure the label exists
|
|
try {
|
|
await github.rest.issues.getLabel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
name: 'invalid-title',
|
|
});
|
|
} catch {
|
|
await github.rest.issues.createLabel({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
name: 'invalid-title',
|
|
color: 'e4e669',
|
|
description: 'Issue title does not meet quality standards',
|
|
});
|
|
}
|
|
|
|
await github.rest.issues.addLabels({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.issue.number,
|
|
labels: ['invalid-title'],
|
|
});
|
|
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.issue.number,
|
|
body: [
|
|
'## Invalid title',
|
|
'',
|
|
`Your issue title \`${title}\` is too generic to be actionable.`,
|
|
'',
|
|
'Please edit the title to something descriptive that summarizes the problem — for example:',
|
|
'> _Map view crashes when zooming in on Safari 17_',
|
|
'',
|
|
'**This issue will be automatically closed in 24 hours if the title has not been updated.**',
|
|
].join('\n'),
|
|
});
|
|
|
|
} else if (featureRequestTitles.some(t => titleLower.startsWith(t))) {
|
|
await github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.issue.number,
|
|
body: [
|
|
'## Wrong place for feature requests',
|
|
'',
|
|
'Feature requests should be submitted in [Discussions](https://github.com/liketrek/TREK/discussions/new?category=feature-requests), not as issues.',
|
|
'',
|
|
'This issue has been closed. Feel free to re-submit your idea in the right place!',
|
|
].join('\n'),
|
|
});
|
|
|
|
await github.rest.issues.update({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.payload.issue.number,
|
|
state: 'closed',
|
|
state_reason: 'not_planned',
|
|
});
|
|
}
|