forked from tianocore/edk2
-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (46 loc) · 1.63 KB
/
scheduled-maintenance.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# This workflow performs scheduled maintenance tasks.
#
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
name: Scheduled Maintenance
on:
schedule:
# * is a special character in YAML so you have to quote this string
# Run every hour - https://crontab.guru/#0_*_*_*_*
- cron: '0 * * * *'
workflow_dispatch:
jobs:
repo_cleanup:
runs-on: ubuntu-latest
permissions:
pull-requests: write
issues: write
steps:
- name: Prune Won't Fix Pull Requests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
-H "Accept: application/vnd.github+json" \
/repos/${GITHUB_REPOSITORY}/pulls | jq -r '.[]' | jq -rc '.html_url,.labels' | \
while read -r html_url ; do
read -r labels
if [[ $labels == *"state:wont-fix"* ]]; then
gh pr close $html_url -c "Closed due to being marked as wont fix" --delete-branch
fi
done
- name: Prune Won't Fix Issues
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ env.REPOSITORY_NAME }}
run: |
gh api \
-H "Accept: application/vnd.github+json" \
/repos/${GITHUB_REPOSITORY}/issues | jq -r '.[]' | jq -rc '.html_url,.labels' | \
while read -r html_url ; do
read -r labels
if [[ $labels == *"state:wont-fix"* ]]; then
gh issue close $html_url -c "Closed due to being marked as wont fix" -r "not planned"
fi
done