mirror of
https://github.com/shivammathur/setup-php.git
synced 2025-08-20 20:44:46 +07:00
Add authorization header to GitHub API call when COMPOSER_TOKEN is set
This commit is contained in:
@ -52,10 +52,15 @@ export async function getInput(
|
||||
export async function fetch(input_url: string): Promise<string> {
|
||||
const fetch_promise: Promise<string> = new Promise(resolve => {
|
||||
const url_object: url.UrlObject = new url.URL(input_url);
|
||||
const auth_token: string = process.env['COMPOSER_TOKEN'] || '';
|
||||
const auth_header: string = auth_token ? 'Bearer' + auth_token : '';
|
||||
const options: https.RequestOptions = {
|
||||
hostname: url_object.hostname,
|
||||
path: url_object.pathname,
|
||||
headers: {'User-Agent': 'setup-php'}
|
||||
headers: {
|
||||
authorization: auth_header,
|
||||
'User-Agent': 'setup-php'
|
||||
}
|
||||
};
|
||||
const req = https.get(options, (res: IncomingMessage) => {
|
||||
res.setEncoding('utf8');
|
||||
|
Reference in New Issue
Block a user