[Feature request] Themed Icon #65
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Close Issues if Template Ignored | |
on: | |
issues: | |
types: [opened] | |
permissions: | |
issues: write | |
contents: read | |
jobs: | |
close_issues: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check issue body and creation date | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const issueBody = context.payload.issue.body; | |
const issueNumber = context.payload.issue.number; | |
const issueCreatedAt = new Date(context.payload.issue.created_at); | |
const templateKeyword = "**Checklist "; // Change this to a unique part of your template | |
// Define the cutoff date (year, month - 1, day) | |
const cutoffDate = new Date(2024, 11, 2); // December is month 11 (0-based index) | |
// Check if the issue was created after the cutoff date | |
if (issueCreatedAt > cutoffDate) { | |
// Check if the issue body contains the template keyword | |
if (!issueBody.includes(templateKeyword)) { | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
body: "This issue does not follow the template and will be closed. Please update the issue following the template and reopen it." | |
}); | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issueNumber, | |
state: "closed" | |
}); | |
} | |
} |