-
Notifications
You must be signed in to change notification settings - Fork 317
Add scheduled workflow to restart stale PR status checks #6224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
|
Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234' |
1 similar comment
|
Could not find a linked ADO work item. Please link one by using the pattern 'AB#' followed by the relevant work item number. You may use the 'Fixes' keyword to automatically resolve the work item when the pull request is merged. E.g. 'Fixes AB#1234' |
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
| $runId = $matches[1] | ||
| # Validate run ID is a positive integer | ||
| if ([int]$runId -gt 0) { | ||
| gh api --method POST "/repos/$env:GITHUB_REPOSITORY/actions/runs/$runId/rerun" | Out-Null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot you can use the gh run rerun here instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to use gh run rerun command. Commit 49ff744.
| continue | ||
| } | ||
|
|
||
| if ($statusCheck.bucket -ne "pass") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot what is the point of checking the bucket as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the redundant bucket check. If state is "SUCCESS", the bucket is already "pass". Commit 9cfd852.
| Write-Host "Fetching open pull requests..." | ||
|
|
||
| # Get all open pull requests | ||
| $prs = gh pr list --state open --json number,headRefName,title,url --limit 1000 | ConvertFrom-Json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot remove the unused properties. The url might be useful in the logs and summary
| $prs = gh pr list --state open --json number,headRefName,title,url --limit 1000 | ConvertFrom-Json | |
| $prs = gh pr list --state open --json number,title,url --limit 1000 | ConvertFrom-Json |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unused headRefName property. Now only fetching number, title, and url. Commit 9cfd852.
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
| gh run rerun $runId -R $env:GITHUB_REPOSITORY | Out-Null | ||
| Write-Host " ✓ Successfully triggered re-run of workflow (run ID: $runId)" | ||
| $restarted++ | ||
| $success = $true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot how is $success variable used?
Also, consider failing if there are PRs that failed to be processed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed unused $success variable (it was set but never checked). Added exit code 1 with error annotation when any PRs fail to be processed. Commit 60eddd1.
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
| } | ||
| else { | ||
| Write-Host " ✗ Invalid run ID extracted: $runId" | ||
| $failed++ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot Let's count the processed PRs, not the attempts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to count failed PRs instead of failed attempts. Added $prFailed flag that tracks if a PR failed, incrementing $failed counter once per PR regardless of retry attempts. Commit bffa485.
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Plan: Create Scheduled PR Status Check Workflow
RestartPRStatusCheck.yamlgh pr checksinstead of fetching all workflow runsstateandbucketinstead ofstatusandconclusioncompletedAtcheckcontinuepattern for consistencygh run reruninstead of API call for simpler codeheadRefNameproperty from PR list query$successvariableSummary
Changed failure counting to track the number of PRs that failed to be processed, rather than counting each individual retry attempt. Now if a PR fails after 3 retry attempts, it only increments the failed counter once.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.