-
Notifications
You must be signed in to change notification settings - Fork 104
59 lines (54 loc) · 2.13 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
53
54
55
56
57
58
59
# This workflow performs scheduled maintenance tasks.
#
# NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there
# instead of the file in this repo.
#
# NOTE: This file uses reusable workflows. Do not make changes to the file that should be made
# in the common/reusable workflows.
#
# - Mu DevOps Repo: https://github.com/microsoft/mu_devops
# - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml
#
# 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 * * * *'
jobs:
repo_cleanup:
runs-on: ubuntu-latest
steps:
- name: Get Repository Info
run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV
- name: Prune Won't Fix Pull Requests
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPOSITORY: ${{ env.REPOSITORY_NAME }}
run: |
gh api \
-H "Accept: application/vnd.github+json" \
/repos/microsoft/${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/microsoft/${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