Skip to content

Commit

Permalink
Return gracefully if no GitHub API key is available
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Jan 4, 2025
1 parent 41b25e1 commit d77d97d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions site/models/release.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@ protected function allReleases(): array
return $entry['releases'];
}

$releases = [];
foreach (Github::request('getkirby/kirby', 'git/refs/tags')->json() as $release) {
$releases[] = Str::after($release['ref'], 'refs/tags/');
try {
$releases = [];
foreach (Github::request('getkirby/kirby', 'git/refs/tags')->json() as $release) {
$releases[] = Str::after($release['ref'], 'refs/tags/');
}
} catch (InvalidArgumentException) {
// no GitHub API key is available
return [];
}

$cache->set('releases', ['currentVersion' => $kirby->version(), 'releases' => $releases], 10080);
Expand Down

0 comments on commit d77d97d

Please sign in to comment.