Skip to content

Commit 9ed0367

Browse files
committed
update issues template to newer github flow
1 parent 5f5e7ca commit 9ed0367

File tree

5 files changed

+16
-74
lines changed

5 files changed

+16
-74
lines changed

ISSUE_TEMPLATE.md renamed to .github/ISSUE_TEMPLATE/expired-flag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ This issue was automatically created by the [LaunchDarkly Feature Flag Expiry Au
2323
**Audit Date**: {{auditDate}}
2424

2525
---
26-
⚠️ **Important**: Please review this flag's usage before deletion to avoid breaking functionality.
26+
⚠️ **Important**: Please review this flag's usage before deletion to avoid breaking functionality.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ The action can automatically create GitHub issues for expired flags using the `c
159159
160160
### Issue Template
161161
162-
The action looks for an `ISSUE_TEMPLATE.md` file in your repository root. If not found, it uses a built-in template. You can customize the template with these placeholders:
162+
The action uses the template located at `.github/ISSUE_TEMPLATE/expired-flag.md`:
163163

164164
- `{{flagName}}` - The display name of the flag
165165
- `{{flagKey}}` - The flag key

dist/ISSUE_TEMPLATE.md renamed to dist/expired-flag.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ This issue was automatically created by the [LaunchDarkly Feature Flag Expiry Au
2323
**Audit Date**: {{auditDate}}
2424

2525
---
26-
⚠️ **Important**: Please review this flag's usage before deletion to avoid breaking functionality.
26+
⚠️ **Important**: Please review this flag's usage before deletion to avoid breaking functionality.

dist/index.js

Lines changed: 7 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -495,15 +495,16 @@ async function createGitHubIssues(pastDueFlags, isAuditingAllProjects) {
495495
const octokit = github.getOctokit(token);
496496
const { owner, repo } = github.context.repo;
497497

498-
// Read issue template
499-
const templatePath = __nccwpck_require__.ab + "ISSUE_TEMPLATE.md";
498+
// Read issue template from .github/ISSUE_TEMPLATE/expired-flag.md
499+
const templatePath = __nccwpck_require__.ab + "expired-flag.md";
500500
let issueTemplate;
501501

502502
try {
503-
issueTemplate = fs.readFileSync(__nccwpck_require__.ab + "ISSUE_TEMPLATE.md", 'utf8');
503+
issueTemplate = fs.readFileSync(__nccwpck_require__.ab + "expired-flag.md", 'utf8');
504+
core.debug(`Using issue template from: ${templatePath}`);
504505
} catch (error) {
505-
core.debug('ISSUE_TEMPLATE.md not found, using default template');
506-
issueTemplate = getDefaultIssueTemplate();
506+
core.setFailed(`Issue template not found at: ${templatePath}. Please ensure the template file exists.`);
507+
return 0;
507508
}
508509

509510
let issuesCreated = 0;
@@ -563,37 +564,7 @@ async function createGitHubIssues(pastDueFlags, isAuditingAllProjects) {
563564
return issuesCreated;
564565
}
565566

566-
/**
567-
* Default issue template if ISSUE_TEMPLATE.md is not found
568-
*/
569-
function getDefaultIssueTemplate() {
570-
return `# 🚨 Expired LaunchDarkly Feature Flag: {{flagName}}
571-
572-
## Flag Details
573-
- **Flag Name**: \`{{flagName}}\`
574-
- **Flag Key**: \`{{flagKey}}\`
575-
- **Expired Date**: {{expiryDate}}
576-
- **Days Overdue**: {{daysOverdue}} days
577-
578-
## Action Required
579-
This feature flag has expired and should be reviewed for cleanup.
580567

581-
### Cleanup Steps
582-
- [ ] Review flag usage in codebase
583-
- [ ] Verify flag is no longer needed
584-
- [ ] Remove flag references from code
585-
- [ ] Archive flag in LaunchDarkly
586-
- [ ] Close this issue
587-
588-
### Context
589-
This issue was automatically created by the LaunchDarkly Feature Flag Expiry Audit Action.
590-
591-
**Project**: {{projectName}} ({{projectKey}})
592-
**Audit Date**: {{auditDate}}
593-
594-
---
595-
⚠️ **Important**: Please review this flag's usage before deletion to avoid breaking functionality.`;
596-
}
597568

598569
// Polyfill for fetch if not available
599570
if (typeof fetch === 'undefined') {
@@ -604,7 +575,7 @@ if (require.main === require.cache[eval('__filename')]) {
604575
run();
605576
}
606577

607-
module.exports = { run, parseExpiryDate, filterFlagsWithExpiryDates, logFlagsTable, createGitHubIssues, getDefaultIssueTemplate, getAllProjects };
578+
module.exports = { run, parseExpiryDate, filterFlagsWithExpiryDates, logFlagsTable, createGitHubIssues, getAllProjects };
608579

609580

610581

index.js

Lines changed: 6 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -489,15 +489,16 @@ async function createGitHubIssues(pastDueFlags, isAuditingAllProjects) {
489489
const octokit = github.getOctokit(token);
490490
const { owner, repo } = github.context.repo;
491491

492-
// Read issue template
493-
const templatePath = path.join(process.cwd(), 'ISSUE_TEMPLATE.md');
492+
// Read issue template from .github/ISSUE_TEMPLATE/expired-flag.md
493+
const templatePath = path.join(process.cwd(), '.github', 'ISSUE_TEMPLATE', 'expired-flag.md');
494494
let issueTemplate;
495495

496496
try {
497497
issueTemplate = fs.readFileSync(templatePath, 'utf8');
498+
core.debug(`Using issue template from: ${templatePath}`);
498499
} catch (error) {
499-
core.debug('ISSUE_TEMPLATE.md not found, using default template');
500-
issueTemplate = getDefaultIssueTemplate();
500+
core.setFailed(`Issue template not found at: ${templatePath}. Please ensure the template file exists.`);
501+
return 0;
501502
}
502503

503504
let issuesCreated = 0;
@@ -557,37 +558,7 @@ async function createGitHubIssues(pastDueFlags, isAuditingAllProjects) {
557558
return issuesCreated;
558559
}
559560

560-
/**
561-
* Default issue template if ISSUE_TEMPLATE.md is not found
562-
*/
563-
function getDefaultIssueTemplate() {
564-
return `# 🚨 Expired LaunchDarkly Feature Flag: {{flagName}}
565-
566-
## Flag Details
567-
- **Flag Name**: \`{{flagName}}\`
568-
- **Flag Key**: \`{{flagKey}}\`
569-
- **Expired Date**: {{expiryDate}}
570-
- **Days Overdue**: {{daysOverdue}} days
571-
572-
## Action Required
573-
This feature flag has expired and should be reviewed for cleanup.
574561

575-
### Cleanup Steps
576-
- [ ] Review flag usage in codebase
577-
- [ ] Verify flag is no longer needed
578-
- [ ] Remove flag references from code
579-
- [ ] Archive flag in LaunchDarkly
580-
- [ ] Close this issue
581-
582-
### Context
583-
This issue was automatically created by the LaunchDarkly Feature Flag Expiry Audit Action.
584-
585-
**Project**: {{projectName}} ({{projectKey}})
586-
**Audit Date**: {{auditDate}}
587-
588-
---
589-
⚠️ **Important**: Please review this flag's usage before deletion to avoid breaking functionality.`;
590-
}
591562

592563
// Polyfill for fetch if not available
593564
if (typeof fetch === 'undefined') {
@@ -598,5 +569,5 @@ if (require.main === module) {
598569
run();
599570
}
600571

601-
module.exports = { run, parseExpiryDate, filterFlagsWithExpiryDates, logFlagsTable, createGitHubIssues, getDefaultIssueTemplate, getAllProjects };
572+
module.exports = { run, parseExpiryDate, filterFlagsWithExpiryDates, logFlagsTable, createGitHubIssues, getAllProjects };
602573

0 commit comments

Comments
 (0)