Skip to content

Commit

Permalink
Merge pull request #64 from Laravel-Lang/patch/2024-04-01/01-20
Browse files Browse the repository at this point in the history
Added action for resetting all webhooks from repositories
  • Loading branch information
andrey-helldar authored Mar 31, 2024
2 parents 57cc665 + 9f26628 commit 3ba8adb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions actions/2024_04_01_010149_remove_unnecessary_webhooks.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php

declare(strict_types=1);

use DragonCode\LaravelActions\Action;
use GrahamCampbell\GitHub\GitHubManager;

return new class extends Action {
protected bool $before = false;

protected string $organization = 'Laravel-Lang';

public function __invoke(GitHubManager $github): void
{
foreach ($this->repositories($github) as $repository) {
foreach ($this->webhooks($github, $repository['name']) as $webhook) {
$this->remove($github, $repository['name'], $webhook['id']);
}
}
}

protected function remove(GitHubManager $github, string $repository, int $id): void
{
$github->repository()->hooks()->remove($this->organization, $repository, $id);
}

protected function repositories(GitHubManager $github): array
{
return $github->organization()->repositories($this->organization);
}

protected function webhooks(GitHubManager $github, string $repository): array
{
return $github->repository()->hooks()->all($this->organization, $repository);
}
};

0 comments on commit 3ba8adb

Please sign in to comment.