Skip to content

Commit 46fe5ae

Browse files
authored
Merge pull request #29 from wojsmol/add/token
Add GITHUB_TOKEN enviroment variable support
2 parents aee710e + a67ad4a commit 46fe5ae

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

.maintenance/clone-all-repositories.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@
1313
);
1414

1515
$request = 'https://api.github.com/orgs/wp-cli/repos?per_page=100';
16+
$headers = '';
17+
$token = getenv( 'GITHUB_TOKEN' );
18+
if (!empty($token)) {
19+
$headers = '--header "Authorization: token $token"';
20+
$response = shell_exec( "curl -s {$headers} {$request}" );
21+
}
22+
else
23+
{
1624
$response = shell_exec( "curl -s {$request}" );
25+
}
1726
$repositories = json_decode( $response );
1827
if ( ! is_array( $repositories ) && property_exists( $repositories, 'message' ) ) {
1928
echo "GitHub responded with: " . $repositories->message . "\n";
20-
echo "If you are running into a rate limiting issue during large events please consider using a different network to install the wp-cli development environment.\n";
29+
echo "If you are running into a rate limiting issue during large events please set GITHUB_TOKEN environment variable.\n";
2130
exit( 1 );
2231
}
2332

0 commit comments

Comments
 (0)