Arulkumar03/Wheat_HEAD_Detection_Counting_ComputerVision_Model
0
1name: Close/Lock issues after inactivity2 3on:4 schedule:5 - cron: "0 0 * * *"6 7jobs:8 close-issues-needs-more-info:9 runs-on: ubuntu-latest10 if: ${{ github.repository_owner == 'facebookresearch' }}11 steps:12 - name: Close old issues that need reply13 uses: actions/github-script@v314 with:15 github-token: ${{secrets.GITHUB_TOKEN}}16 # Modified from https://github.com/dwieeb/needs-reply17 script: |18 // Arguments available:19 // - github: A pre-authenticated octokit/rest.js client20 // - context: An object containing the context of the workflow run21 // - core: A reference to the @actions/core package22 // - io: A reference to the @actions/io package23 const kLabelToCheck = "needs-more-info";24 const kInvalidLabel = "invalid/unrelated";25 const kDaysBeforeClose = 7;26 const kMessage = "Requested information was not provided in 7 days, so we're closing this issue.\n\nPlease open new issue if information becomes available. Otherwise, use [github discussions](https://github.com/facebookresearch/detectron2/discussions) for free-form discussions."27 28 issues = await github.issues.listForRepo({29 owner: context.repo.owner,30 repo: context.repo.repo,31 state: 'open',32 labels: kLabelToCheck,33 sort: 'updated',34 direction: 'asc',35 per_page: 30,36 page: 1,37 });38 issues = issues.data;39 if (issues.length === 0) {40 core.info('No more issues found to process. Exiting.');41 return;42 }43 for (const issue of issues) {44 if (!!issue.pull_request)45 continue;46 core.info(`Processing issue #${issue.number}`);47 48 let updatedAt = new Date(issue.updated_at).getTime();49 const numComments = issue.comments;50 const comments = await github.issues.listComments({51 owner: context.repo.owner,52 repo: context.repo.repo,53 issue_number: issue.number,54 per_page: 30,55 page: Math.floor((numComments - 1) / 30) + 1, // the last page56 });57 const lastComments = comments.data58 .map(l => new Date(l.created_at).getTime())59 .sort();60 if (lastComments.length > 0) {61 updatedAt = lastComments[lastComments.length - 1];62 }63 64 const now = new Date().getTime();65 const daysSinceUpdated = (now - updatedAt) / 1000 / 60 / 60 / 24;66 67 if (daysSinceUpdated < kDaysBeforeClose) {68 core.info(`Skipping #${issue.number} because it has been updated in the last ${daysSinceUpdated} days`);69 continue;70 }71 core.info(`Closing #${issue.number} because it has not been updated in the last ${daysSinceUpdated} days`);72 await github.issues.createComment({73 owner: context.repo.owner,74 repo: context.repo.repo,75 issue_number: issue.number,76 body: kMessage,77 });78 const newLabels = numComments <= 2 ? [kInvalidLabel, kLabelToCheck] : issue.labels;79 await github.issues.update({80 owner: context.repo.owner,81 repo: context.repo.repo,82 issue_number: issue.number,83 labels: newLabels,84 state: 'closed',85 });86 }87 88 lock-issues-after-closed:89 runs-on: ubuntu-latest90 if: ${{ github.repository_owner == 'facebookresearch' }}91 steps:92 - name: Lock closed issues that have no activity for a while93 uses: dessant/lock-threads@v294 with:95 github-token: ${{ github.token }}96 issue-lock-inactive-days: '300'97 process-only: 'issues'98 issue-exclude-labels: 'enhancement,bug,documentation'99 