guibranco / gstraccini-bot-service

🤖 :octocat: GStraccini-bot automates repository management, ensuring organization and health by handling pull requests, issues, comments, and commits.
https://gstraccini.bot
MIT License
2 stars 0 forks source link

[FEATURE] Block PR until requested review response #379

Open guibranco opened 3 months ago

guibranco commented 3 months ago

Description

We need to configure the status check of pull requests (PRs) to action required until someone from the required reviewer list approves the PR. This will ensure that PRs cannot be merged until they have been reviewed and approved.

Tech Notes

  1. Status Check Configuration:

    • Implement a status check that is set to action required until a review is completed.
    • The status message should display the current PR status, such as awaiting review.
  2. Implementation Example:

    Below is a PHP example using the Request class from the GuiBranco/Pancake library to update the PR status check:

    use GuiBranco\Pancake\Request;
    
    class StatusChecker
    {
       private $token;
       private $repoOwner;
       private $repoName;
       private $apiUrl = 'https://api.github.com';
    
       public function __construct($token, $repoOwner, $repoName)
       {
           $this->token = $token;
           $this->repoOwner = $repoOwner;
           $this->repoName = $repoName;
       }
    
       public function setStatusCheck($prNumber)
       {
           $url = "{$this->apiUrl}/repos/{$this->repoOwner}/{$this->repoName}/statuses/{$prNumber}";
    
           $request = new Request();
           $response = $request->post($url, [
                   'state'       => 'error',
                   'description' => 'Awaiting review',
                   'context'     => 'PR Review Status',
               ],
               [
                   'Authorization' => "token {$this->token}",
                   'Accept'        => 'application/vnd.github.v3+json',
               ]
           );
    
           return $response->body);
       }
    }
    
    // Usage example
    $statusChecker = new StatusChecker('your-github-token', 'your-repo-owner', 'your-repo-name');
    $result = $statusChecker->setStatusCheck(123); // Replace 123 with the actual PR number
    echo $result;
  3. Resources:

Expected Outcome

gitauto-ai[bot] commented 3 months ago

Click the checkbox below to generate a PR!

You have 1 request left in this cycle which refreshes on 2024-08-21 10:07:38. If you have any questions or concerns, please contact us at info@gitauto.ai.

gitauto-ai[bot] commented 2 weeks ago

Hey, I'm a bit lost here! Not sure which file I should be fixing. Could you give me a bit more to go on? Maybe add some details to the issue or drop a comment with some extra hints? Thanks!

Have feedback or need help? Feel free to email info@gitauto.ai.