Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 20, 2026

Plan: Create Scheduled PR Status Check Workflow

  • Explore existing workflows and understand patterns
  • Create new workflow file: RestartPRStatusCheck.yaml
  • Implement workflow to run every 72 hours (3 days)
  • Add logic to query and restart stale checks
  • Test and verify the workflow logic
  • Address PR review comments (round 1)
    • Change job name to "Restart Stale PR Status Checks"
    • Use gh pr checks instead of fetching all workflow runs
    • Add failed attempts tracking and retry logic
  • Address PR review comments (round 2)
    • Extract code to separate action file
    • Add GitHub Actions notice when no PRs found
    • Fix to use correct fields: state and bucket instead of status and conclusion
    • Remove unnecessary completedAt check
    • Use continue pattern for consistency
    • Add workflow run summary
  • Address PR review comments (round 3)
    • Use gh run rerun instead of API call for simpler code
    • Remove redundant bucket check (state already implies bucket)
    • Remove unused headRefName property from PR list query
  • Address PR review comments (round 4)
    • Remove unused $success variable
    • Exit with error code 1 if any PRs failed to be processed
    • Count failed PRs instead of failed retry attempts
  • Final verification

Summary

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.

Copilot AI and others added 3 commits January 20, 2026 13:51
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>
Copilot AI changed the title [WIP] Add workflow to restart PR checks every 72 hours Add scheduled workflow to restart stale PR status checks Jan 20, 2026
Copilot AI requested a review from mazhelez January 20, 2026 13:58
Copilot AI and others added 2 commits January 20, 2026 14:25
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Co-authored-by: mazhelez <43066499+mazhelez@users.noreply.github.com>
Copilot AI requested a review from mazhelez January 20, 2026 14:28
@github-actions github-actions bot added the Build: Automation Workflows and other setup in .github folder label Jan 22, 2026
@github-actions
Copy link

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
@github-actions
Copy link

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>
Copilot AI requested a review from mazhelez January 22, 2026 09:54
Write-Host " Status check is older than $thresholdHours hours, requesting rerun..."

# Try to rerequest the check with retries
$success = $false

Check warning

Code scanning / PSScriptAnalyzer

The variable 'success' is assigned but never used.

The variable 'success' is assigned but never used.
$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
Copy link
Contributor

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.

Copy link
Contributor Author

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") {
Copy link
Contributor

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?

Copy link
Contributor Author

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
Copy link
Contributor

@mazhelez mazhelez Jan 22, 2026

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

Suggested change
$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

Copy link
Contributor Author

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
Copy link
Contributor

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.

Copy link
Contributor Author

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>
Copilot AI requested a review from mazhelez January 22, 2026 12:26
}
else {
Write-Host " ✗ Invalid run ID extracted: $runId"
$failed++
Copy link
Contributor

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.

Copy link
Contributor Author

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>
Copilot AI requested a review from mazhelez January 22, 2026 12:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Build: Automation Workflows and other setup in .github folder

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants