From ed84b11847785792767b0b84cc6f98f4ea08ca77 Mon Sep 17 00:00:00 2001 From: Wes Haggard Date: Wed, 8 Nov 2023 15:47:56 -0800 Subject: [PATCH] Delete .github/workflows/comment.yml (#26632) New gitops condition works so we don't need this workflow any longer. See tests of the policy bot doing this work at https://github.com/Azure/azure-rest-api-specs/pull/26631 Needed a few commits to get it right but you can see the history of the configuration at https://github.com/Azure/azure-rest-api-specs/commits/main/.github/policies/resourceManagement.yml --- .github/workflows/comment.yml | 67 ----------------------------------- 1 file changed, 67 deletions(-) delete mode 100644 .github/workflows/comment.yml diff --git a/.github/workflows/comment.yml b/.github/workflows/comment.yml deleted file mode 100644 index 5441d219fe34..000000000000 --- a/.github/workflows/comment.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Comment Processor - -on: - issue_comment: - types: [created] - -permissions: { } - -jobs: - comment-handler: - permissions: - pull-requests: write # to read pull requests and write comments - repository-projects: read # Workaround issue with cli trying to read projects during edit - name: Handle ${{ github.event_name }} ${{ github.event.action }} event - runs-on: ubuntu-latest - steps: - - name: Process comment - shell: pwsh - run: | - $payload = Write-Output $env:PAYLOAD | ConvertFrom-Json -AsHashtable - if (!$payload.comment -or !$payload.comment.body) { - Write-Host "Skipping: empty comment." - return - } - $body = $payload.comment.body.Trim().ToLowerInvariant() - $expected = '/pr requestmerge' - if ($body -ne $expected) { - Write-Host "Skipping: comment did not equal '$expected'." - return - } - $label = 'MergeRequested' - - $retryCount = 0 - $maxRetries = 5 - $retryDelay = 5 # Initial retry delay in seconds - - while ($retryCount -lt $maxRetries) { - - Write-Host "Attempt $($retryCount+1) out of $($maxRetries): gh pr edit $($payload.issue.number) --add-label `"$label`"" - gh pr edit $payload.issue.html_url --add-label "$label" - - if ($LASTEXITCODE -eq 0) { - Write-Host "Label added successfully on attempt $($retryCount+1) out of $($maxRetries)." - break - } else { - Write-Warning "Failed to add label on attempt $($retryCount+1) out of $($maxRetries)." - $retryCount++ - if ($retryCount -lt $maxRetries) { - # $retryDelay = 5 exponential backoff in seconds: - # attempt 2: 5 = 1*5 - # attempt 3: 10 = 2*5 - # attempt 4: 20 = 4*5 - # attempt 5: 40 = 8*5 - Write-Host "Sleeping for $retryDelay seconds..." - Start-Sleep -Seconds $retryDelay - $retryDelay = $retryDelay * 2 - } - } - } - - if ($retryCount -ge $maxRetries) { - Write-Error "Max retry attempts of $maxRetries exhausted. Exiting with error ('exit 1')." - exit 1 - } - env: - PAYLOAD: ${{ toJson(github.event) }} - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}