Skip to content

Commit 81e25cf

Browse files
authored
Merge pull request #126 from nextcloud/feat/auth_token
2 parents 30fb88c + e15d829 commit 81e25cf

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

changelog/index.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ protected function authenticateGithubClient(\Github\Client $client) {
174174
throw new Exception('Credentials file is missing - please provide your credentials in credentials.json in the root folder.');
175175
}
176176

177+
// Check the env variable
178+
if (getenv('GITHUB_TOKEN')) {
179+
$client->authenticate(getenv('GITHUB_TOKEN'), Github\Client::AUTH_ACCESS_TOKEN);
180+
return;
181+
}
182+
177183
$credentialsData = json_decode(file_get_contents(__DIR__ . '/../credentials.json'), true);
178184
if (!is_array($credentialsData) || !isset($credentialsData['apikey'])) {
179185
throw new Exception('Credentials file can not be read or does not provide "apikey".');
@@ -209,9 +215,12 @@ protected function execute(InputInterface $input, OutputInterface $output)
209215
throw new Exception('Credentials file is missing - please provide your credentials in credentials.json in the root folder.');
210216
}
211217

212-
$credentialsData = json_decode(file_get_contents(__DIR__ . '/../credentials.json'), true);
213-
if (!is_array($credentialsData) || !isset($credentialsData['apikey'])) {
214-
throw new Exception('Credentials file can not be read or does not provide "apikey".');
218+
// Check that we have valid credentials
219+
if (!getenv('GITHUB_TOKEN')) {
220+
$credentialsData = json_decode(file_get_contents(__DIR__ . '/../credentials.json'), true);
221+
if (!is_array($credentialsData) || !isset($credentialsData['apikey'])) {
222+
throw new Exception('Credentials file can not be read or does not provide "apikey".');
223+
}
215224
}
216225

217226
$format = $input->getOption('format');

0 commit comments

Comments
 (0)