mirror of
https://github.com/supabase/setup-cli.git
synced 2026-02-11 21:01:39 +00:00
fix: authenticate with github api
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import os from 'os'
|
import os from 'os'
|
||||||
import * as httpm from '@actions/http-client'
|
import * as httpm from '@actions/http-client'
|
||||||
|
import {BearerCredentialHandler} from '@actions/http-client/lib/auth'
|
||||||
|
|
||||||
interface GitHubTag {
|
interface GitHubTag {
|
||||||
tag_name: string
|
tag_name: string
|
||||||
@@ -32,12 +33,16 @@ export const getDownloadUrl = async (version: string): Promise<string> => {
|
|||||||
return `https://github.com/supabase/cli/releases/download/v${resolvedVersion}/${filename}.tar.gz`
|
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<string> => {
|
const resolveVersion = async (version: string): Promise<string> => {
|
||||||
if (version !== 'latest') {
|
if (version !== 'latest') {
|
||||||
return version
|
return version
|
||||||
}
|
}
|
||||||
|
|
||||||
const http: httpm.HttpClient = new httpm.HttpClient('setup-cli')
|
|
||||||
const url = 'https://api.github.com/repos/supabase/cli/releases/latest'
|
const url = 'https://api.github.com/repos/supabase/cli/releases/latest'
|
||||||
const tag = (await http.getJson<GitHubTag>(url)).result?.tag_name
|
const tag = (await http.getJson<GitHubTag>(url)).result?.tag_name
|
||||||
if (!tag) {
|
if (!tag) {
|
||||||
|
|||||||
Reference in New Issue
Block a user