mirror of
https://github.com/crazywhalecc/static-php-cli.git
synced 2026-07-22 00:05:37 +08:00
What's this???
This commit is contained in:
@@ -15,19 +15,21 @@ class CurlHook
|
|||||||
*/
|
*/
|
||||||
public static function setupGithubToken(string $method, string $url, array &$headers): void
|
public static function setupGithubToken(string $method, string $url, array &$headers): void
|
||||||
{
|
{
|
||||||
if (!getenv('GITHUB_TOKEN')) {
|
$token = getenv('GITHUB_TOKEN');
|
||||||
|
if (!$token) {
|
||||||
logger()->debug('no github token found, skip');
|
logger()->debug('no github token found, skip');
|
||||||
|
var_dump($token);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getenv('GITHUB_USER')) {
|
if (getenv('GITHUB_USER')) {
|
||||||
$auth = base64_encode(getenv('GITHUB_USER') . ':' . getenv('GITHUB_TOKEN'));
|
$auth = base64_encode(getenv('GITHUB_USER') . ':' . $token);
|
||||||
$he = "Authorization: Basic {$auth}";
|
$he = "Authorization: Basic {$auth}";
|
||||||
if (!in_array($he, $headers)) {
|
if (!in_array($he, $headers)) {
|
||||||
$headers[] = $he;
|
$headers[] = $he;
|
||||||
}
|
}
|
||||||
logger()->info("using basic github token for {$method} {$url}");
|
logger()->info("using basic github token for {$method} {$url}");
|
||||||
} else {
|
} else {
|
||||||
$auth = getenv('GITHUB_TOKEN');
|
$auth = $token;
|
||||||
$he = "Authorization: Bearer {$auth}";
|
$he = "Authorization: Bearer {$auth}";
|
||||||
if (!in_array($he, $headers)) {
|
if (!in_array($he, $headers)) {
|
||||||
$headers[] = $he;
|
$headers[] = $he;
|
||||||
|
|||||||
Reference in New Issue
Block a user