Skip to content

Commit

Permalink
MA-17028: test strategy label on ignored issue workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
Pronin-vk committed Aug 12, 2024
1 parent 241e2ef commit fdae4d6
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions .github/workflows/set_label_for_ignored_issues.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
name: Set Pay attention label for ignored issues
on:
schedule:
- cron: '0 11 */2 * *'
- cron: '0 11 */7 * *'
workflow_dispatch:

jobs:
set-label-for-issues:
runs-on: ubuntu-latest
steps:
- name: Set label for issues
if: github.event.schedule == '0 11 */2 * *'
- name: Set Pay attention label for ignored issues
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -19,29 +17,11 @@ jobs:
})
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 == '0 11 */7 * *'
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) {
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,
Expand Down

0 comments on commit fdae4d6

Please sign in to comment.