|
| 1 | +name: GitHub Scheduled Event Processor |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # These are generated/confirmed using https://crontab.cronhub.io/ |
| 6 | + # Close stale issues, runs every day at 1am - CloseStaleIssues |
| 7 | + - cron: '0 1 * * *' |
| 8 | + # Identify stale pull requests, every Friday at 5am - IdentifyStalePullRequests |
| 9 | + - cron: '0 5 * * FRI' |
| 10 | + # Close stale pull requests, every 6 hours at 02:30 AM, 08:30 AM, 02:30 PM and 08:30 PM - CloseStalePullRequests |
| 11 | + - cron: '30 2,8,14,20 * * *' |
| 12 | + # Identify stale issues, every 6 hours at 03:30 AM, 09:30 AM, 03:30 PM and 09:30 PM - IdentifyStaleIssues |
| 13 | + - cron: '30 3,9,15,21 * * *' |
| 14 | + # Close addressed issues, every 6 hours at 04:30 AM, 10:30 AM, 04:30 PM and 10:30 PM - CloseAddressedIssues |
| 15 | + - cron: '30 4,10,16,22 * * *' |
| 16 | + # Lock closed issues, every 6 hours at 05:30 AM, 11:30 AM, 05:30 PM and 11:30 PM - LockClosedIssues |
| 17 | + - cron: '30 5,11,17,23 * * *' |
| 18 | + # Enforce max life of issues, every M,W,F at 10:00 AM PST - EnforceMaxLifeOfIssues |
| 19 | + # Note: GitHub uses UTC, to run at 10am PST, the cron task needs to be 6pm (1800 hours) UTC |
| 20 | + # When scheduling for multiple days the numeric days 0-6 (0=Sunday) must be used. |
| 21 | + - cron: '0 18 * * 1,3,5' |
| 22 | +# This removes all unnecessary permissions, the ones needed will be set below. |
| 23 | +# https://docs.github.com/en/actions/security-guides/automatic-token-authentication#permissions-for-the-github_token |
| 24 | +permissions: {} |
| 25 | + |
| 26 | +jobs: |
| 27 | + event-handler: |
| 28 | + permissions: |
| 29 | + issues: write |
| 30 | + pull-requests: write |
| 31 | + name: Handle ${{ github.event.schedule }} ${{ github.event.action }} event |
| 32 | + runs-on: ubuntu-latest |
| 33 | + steps: |
| 34 | + # To run github-event-processor built from source, for testing purposes, uncomment everything |
| 35 | + # in between the Start/End-Build From Source comments and comment everything in between the |
| 36 | + # Start/End-Install comments |
| 37 | + # Start-Install |
| 38 | + - name: Install GitHub Event Processor |
| 39 | + run: > |
| 40 | + dotnet tool install |
| 41 | + Azure.Sdk.Tools.GitHubEventProcessor |
| 42 | + --version 1.0.0-dev.20240917.2 |
| 43 | + --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json |
| 44 | + --global |
| 45 | + shell: bash |
| 46 | + # End-Install |
| 47 | + |
| 48 | + # Testing checkout of sources from the Azure/azure-sdk-tools repository |
| 49 | + # The ref: is the SHA from the pull request in that repository or the |
| 50 | + # refs/pull/<PRNumber>/merge for the latest on any given PR. If the repository |
| 51 | + # is a fork eg. <User>/azure-sdk-tools then the repository down below will |
| 52 | + # need to point to that fork |
| 53 | + # Start-Build |
| 54 | + # - name: Checkout tools repo for GitHub Event Processor sources |
| 55 | + # uses: actions/checkout@v3 |
| 56 | + # with: |
| 57 | + # repository: Azure/azure-sdk-tools |
| 58 | + # path: azure-sdk-tools |
| 59 | + # ref: <refs/pull/<PRNumber>/merge> or <sha> |
| 60 | + |
| 61 | + # - name: Build and install GitHubEventProcessor from sources |
| 62 | + # run: | |
| 63 | + # dotnet pack |
| 64 | + # dotnet tool install --global --prerelease --add-source ../../../artifacts/packages/Debug Azure.Sdk.Tools.GitHubEventProcessor |
| 65 | + # shell: bash |
| 66 | + # working-directory: azure-sdk-tools/tools/github-event-processor/Azure.Sdk.Tools.GitHubEventProcessor |
| 67 | + # End-Build |
| 68 | + |
| 69 | + - name: Close Stale Issues Scheduled Event |
| 70 | + if: github.event.schedule == '0 1 * * *' |
| 71 | + run: | |
| 72 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} CloseStaleIssues |
| 73 | + shell: bash |
| 74 | + env: |
| 75 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 76 | + |
| 77 | + - name: Identify Stale PullRequests Scheduled Event |
| 78 | + if: github.event.schedule == '0 5 * * FRI' |
| 79 | + run: | |
| 80 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} IdentifyStalePullRequests |
| 81 | + shell: bash |
| 82 | + env: |
| 83 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + |
| 85 | + - name: Close Stale PullRequests Scheduled Event |
| 86 | + if: github.event.schedule == '30 2,8,14,20 * * *' |
| 87 | + run: | |
| 88 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} CloseStalePullRequests |
| 89 | + shell: bash |
| 90 | + env: |
| 91 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 92 | + |
| 93 | + - name: Identify Stale Issues Scheduled Event |
| 94 | + if: github.event.schedule == '30 3,9,15,21 * * *' |
| 95 | + run: | |
| 96 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} IdentifyStaleIssues |
| 97 | + shell: bash |
| 98 | + env: |
| 99 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 100 | + |
| 101 | + - name: Close Addressed Issues Scheduled Event |
| 102 | + if: github.event.schedule == '30 4,10,16,22 * * *' |
| 103 | + run: | |
| 104 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} CloseAddressedIssues |
| 105 | + shell: bash |
| 106 | + env: |
| 107 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 108 | + |
| 109 | + - name: Lock Closed Issues Scheduled Event |
| 110 | + if: github.event.schedule == '30 5,11,17,23 * * *' |
| 111 | + run: | |
| 112 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} LockClosedIssues |
| 113 | + shell: bash |
| 114 | + env: |
| 115 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + |
| 117 | + - name: Enforce Max Life of Issues Scheduled Event |
| 118 | + if: github.event.schedule == '0 18 * * 1,3,5' |
| 119 | + run: | |
| 120 | + github-event-processor ${{ github.event_name }} ${{ github.event_path }} EnforceMaxLifeOfIssues |
| 121 | + shell: bash |
| 122 | + env: |
| 123 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 124 | + |
| 125 | + - name: Archive github event data |
| 126 | + uses: actions/upload-artifact@v4 |
| 127 | + if: always() |
| 128 | + with: |
| 129 | + name: event |
| 130 | + path: ${{ github.event_path }} |
0 commit comments