Skip to content

Commit b17beb3

Browse files
authored
Merge pull request #5 from Cybrarist/fix/public-repo-doesn't-get-tag
fixed public repo failed to get tag without token
2 parents 2b0cf96 + 81a38fb commit b17beb3

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,11 +202,10 @@ To make this one work, you need to add this keys to our .env file :
202202

203203
```bash
204204
GITHUB_REPOSITORY=user/name-of-the-repo
205-
GITHUB_TOKEN=
205+
GITHUB_TOKEN= # Recommended but not compulsory for all repos, required for private repos
206206
GITHUB_CACHE_TTL= # in seconds, 3600 by default
207207
```
208-
209-
You can generate a token [here](https://github.com/settings/personal-access-tokens). The token need to have at least the `read-only` permission on the "Contents" scope in Repository permissions.
208+
If needed, you can generate a token [here](https://github.com/settings/personal-access-tokens). The token need to have at least the `read-only` permission on the "Contents" scope in Repository permissions.
210209

211210
### Load time
212211
![Filament Easy Footer load time](https://raw.githubusercontent.com/Devonab/filament-easy-footer/main/art/load_time.webp)

src/Services/GitHubService.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,15 @@ public function getLatestTag(?string $repository = null): string
8383
protected function fetchLatestTag(string $repository): ?string
8484
{
8585
try {
86-
$response = Http::withToken($this->token)
86+
$response = Http::when(config('filament-easy-footer.github.token'),fn ($request) => $request->withToken($this->token))
8787
->get("https://api.github.com/repos/{$repository}/releases/latest");
8888

89+
8990
if ($response->successful()) {
9091
return $response->json('tag_name');
9192
}
9293

93-
$tagsResponse = Http::withToken($this->token)
94+
$tagsResponse = Http::when(config('filament-easy-footer.github.token'),fn ($request) => $request->withToken($this->token))
9495
->get("https://api.github.com/repos/{$repository}/tags");
9596

9697
if ($tagsResponse->successful() && ! empty($tagsResponse->json())) {

0 commit comments

Comments
 (0)