Skip to content

Set Pay attention label for ignored issues #10

Set Pay attention label for ignored issues

Set Pay attention label for ignored issues #10

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']
});
}
}
}