Set Pay attention label for ignored issues #11
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: Set Pay attention label for ignored issues | |
on: | |
schedule: | |
- cron: '0 10 * * 1-5' | |
jobs: | |
set-label-for-issues: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Set Pay attention label for ignored issues | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.DEVTOOLS_GITHUB_TOKEN }} | |
script: | | |
const issuesList = await github.rest.issues.listForRepo({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
}) | |
if (issuesList.data && issuesList.status === 200) { | |
for (const issue of issuesList.data) { | |
const createdDaysDelta = (new Date() - new Date(issue.created_at)) / (1000 * 60 * 60 * 24); | |
if (!issue.labels.length && ( | |
(!issue.pull_request && createdDaysDelta > 2) || (issue.pull_request && createdDaysDelta > 7) | |
)) { | |
await github.rest.issues.addLabels({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue.number, | |
labels: ['pay attention'] | |
}); | |
} | |
} | |
} |