microsoft/mu_feature_ffa
Publicmirrored fromhttps://github.com/microsoft/mu_feature_ffaAvailable
.github/workflows/scheduled-maintenance.yml
68lines · modecode
| 1 | # This workflow performs scheduled maintenance tasks. |
| 2 | # |
| 3 | # NOTE: This file is automatically synchronized from Mu DevOps. Update the original file there |
| 4 | # instead of the file in this repo. |
| 5 | # |
| 6 | # NOTE: This file uses reusable workflows. Do not make changes to the file that should be made |
| 7 | # in the common/reusable workflows. |
| 8 | # |
| 9 | # - Mu DevOps Repo: https://github.com/microsoft/mu_devops |
| 10 | # - File Sync Settings: https://github.com/microsoft/mu_devops/blob/main/.sync/Files.yml |
| 11 | # |
| 12 | # Copyright (c) Microsoft Corporation. |
| 13 | # SPDX-License-Identifier: BSD-2-Clause-Patent |
| 14 | # |
| 15 | |
| 16 | name: Scheduled Maintenance |
| 17 | |
| 18 | on: |
| 19 | schedule: |
| 20 | # * is a special character in YAML so you have to quote this string |
| 21 | # Run every hour - https://crontab.guru/#0_*_*_*_* |
| 22 | - cron: '0 * * * *' |
| 23 | |
| 24 | jobs: |
| 25 | repo_cleanup: |
| 26 | runs-on: ubuntu-latest |
| 27 | |
| 28 | steps: |
| 29 | - name: Generate Token |
| 30 | id: app-token |
| 31 | uses: actions/create-github-app-token@v2 |
| 32 | with: |
| 33 | app-id: ${{ vars.MU_ACCESS_APP_ID }} |
| 34 | private-key: ${{ secrets.MU_ACCESS_APP_PRIVATE_KEY }} |
| 35 | owner: ${{ github.repository_owner }} |
| 36 | |
| 37 | - name: Get Repository Info |
| 38 | run: echo "REPOSITORY_NAME=${GITHUB_REPOSITORY#*/}" >> $GITHUB_ENV |
| 39 | |
| 40 | - name: Prune Won't Fix Pull Requests |
| 41 | env: |
| 42 | GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
| 43 | REPOSITORY: ${{ env.REPOSITORY_NAME }} |
| 44 | run: | |
| 45 | gh api \ |
| 46 | -H "Accept: application/vnd.github+json" \ |
| 47 | /repos/microsoft/${REPOSITORY}/pulls | jq -r '.[]' | jq -rc '.html_url,.labels' | \ |
| 48 | while read -r html_url ; do |
| 49 | read -r labels |
| 50 | if [[ $labels == *"state:wont-fix"* ]]; then |
| 51 | gh pr close $html_url -c "Closed due to being marked as wont fix" --delete-branch |
| 52 | fi |
| 53 | done |
| 54 | |
| 55 | - name: Prune Won't Fix Issues |
| 56 | env: |
| 57 | GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} |
| 58 | REPOSITORY: ${{ env.REPOSITORY_NAME }} |
| 59 | run: | |
| 60 | gh api \ |
| 61 | -H "Accept: application/vnd.github+json" \ |
| 62 | /repos/microsoft/${REPOSITORY}/issues | jq -r '.[]' | jq -rc '.html_url,.labels' | \ |
| 63 | while read -r html_url ; do |
| 64 | read -r labels |
| 65 | if [[ $labels == *"state:wont-fix"* ]]; then |
| 66 | gh issue close $html_url -c "Closed due to being marked as wont fix" -r "not planned" |
| 67 | fi |
| 68 | done |