Skip to content

Set Pay attention label for ignored issues #1

Set Pay attention label for ignored issues

Set Pay attention label for ignored issues #1

name: Set Pay attention label for ignored issues
on:
schedule:
- cron: '*/6 * * * *'
- cron: '*/9 * * * *'
jobs:
set-label-for-issues:
runs-on: ubuntu-latest
steps:
- name: Set label for issues
if: github.event.schedule == '*/6 * * * *'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.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) {
if (!issue.pull_request && !issue.labels.length) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['pay attention']
});
}
}
}
- name: Set label for pull requests
if: github.event.schedule == '*/9 * * * *'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.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) {
if (issue.pull_request && !issue.labels.length) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
labels: ['pay attention']
});
}
}
}