Skip to content

[Bug] niconico search #47

[Bug] niconico search

[Bug] niconico search #47

Workflow file for this run

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"
});
}
}