Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 19 additions & 7 deletions app/Listeners/GitHubCommentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use App\Helpers\Format;
use App\Models\Build;
use App\Models\Project;
use Github\ResultPager;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;

Expand Down Expand Up @@ -130,7 +131,7 @@ private function buildMessage(array $artifacts, int $base_total_size, int $total

| File name | Previous Size | New Size | Change |
| --------- | ------------- | -------- | ------ |

EOT;
foreach ($artifacts as $artifact) {
$message .= '| ' . $artifact['name'] . ' | ';
Expand Down Expand Up @@ -163,16 +164,27 @@ private function checkForExistingComment(
Project $project,
Build $build
) {
$comments = $github->issue()->comments()->all(
$issueCommentsApi = $github->issue()->comments();
$paginator = new ResultPager($github);
$comments = $paginator->fetch($issueCommentsApi, 'all', [
$project->org_name,
$project->repo_name,
$build->pull_request
);
foreach ($comments as $comment) {
if (ends_with($comment['user']['html_url'], '/apps/' . env('GITHUB_APP_ALIAS'))) {
return $comment['id'];
]);

do {
$hasNext = false;
foreach ($comments as $comment) {
if (ends_with($comment['user']['html_url'], '/apps/' . env('GITHUB_APP_ALIAS'))) {
return $comment['id'];
}
}
}
if ($paginator->hasNext()) {
$hasNext = true;
$comments = $paginator->fetchNext();
}
} while ($hasNext);

return null;
}
}