From b9b7fd42da8b32090d59f6f52afc0f81bdcd0acf Mon Sep 17 00:00:00 2001 From: Qiao Han Date: Wed, 19 Oct 2022 15:40:27 +0800 Subject: [PATCH] fix: authenticate with github api --- src/utils.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/utils.ts b/src/utils.ts index 0f5957a..adf6230 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,6 @@ import os from 'os' import * as httpm from '@actions/http-client' +import {BearerCredentialHandler} from '@actions/http-client/lib/auth' interface GitHubTag { tag_name: string @@ -32,12 +33,16 @@ export const getDownloadUrl = async (version: string): Promise => { return `https://github.com/supabase/cli/releases/download/v${resolvedVersion}/${filename}.tar.gz` } +// Ref: https://github.com/actions/toolkit/blob/main/packages/cache/src/internal/cacheHttpClient.ts#L62 +const http: httpm.HttpClient = new httpm.HttpClient('setup-cli', [ + new BearerCredentialHandler(process.env['ACTIONS_RUNTIME_TOKEN'] || '') +]) + const resolveVersion = async (version: string): Promise => { if (version !== 'latest') { return version } - const http: httpm.HttpClient = new httpm.HttpClient('setup-cli') const url = 'https://api.github.com/repos/supabase/cli/releases/latest' const tag = (await http.getJson(url)).result?.tag_name if (!tag) {