File tree Expand file tree Collapse file tree 8 files changed +886
-1440
lines changed Expand file tree Collapse file tree 8 files changed +886
-1440
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,7 @@ Checkout CLI's [config documentation](https://github.com/scaleway/scaleway-cli/b
3939
4040# ## Others
4141
42+ - `repo-token` : default to the workflow token (i.e. `GITHUB_TOKEN`), needed to check the latest version of the tool available
4243- `version` : default to latest, must be exact version. Fetched from exported config if available
4344- ` access-key`
4445- ` secret-key`
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ branding:
44 icon : terminal
55 color : purple
66inputs :
7+ repo-token :
8+ description : ' The GitHub token, used to check for latest CLI version'
9+ required : false
10+ default : ${{ github.token }}
711 version :
812 description : ' CLI version, will default to latest or exported version'
913 required : false
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -70,11 +70,11 @@ const setPermissions = async (filePath: string) => {
7070 }
7171}
7272
73- export const install = async ( requestedVersion : string ) => {
73+ export const install = async ( requestedVersion : string , repoToken : string ) => {
7474 let version = requestedVersion
7575
7676 if ( requestedVersion === VERSION_LATEST ) {
77- version = await getLatest ( )
77+ version = await getLatest ( repoToken )
7878 }
7979
8080 let toolPath = tc . find ( 'scw' , version )
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export const exportConfig = (args: Args) => {
1212}
1313
1414export const importConfig = ( ) : Args => ( {
15+ repoToken : '' ,
1516 defaultOrganizationID : process . env . SCW_DEFAULT_ORGANIZATION_ID ?? '' ,
1617 defaultProjectID : process . env . SCW_DEFAULT_PROJECT_ID ?? '' ,
1718 secretKey : process . env . SCW_SECRET_KEY ?? '' ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import * as tc from '@actions/tool-cache'
33import { VERSION_LATEST } from './version.js'
44
55export type Args = {
6+ repoToken : string
67 version : string
78 accessKey : string
89 secretKey : string
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { CLIError, run } from './run.js'
77import { VERSION_LATEST } from './version.js'
88
99const getArgs = ( defaultArgs : Args ) : Args => ( {
10+ repoToken : core . getInput ( 'repo-token' ) || defaultArgs . repoToken ,
1011 version : core . getInput ( 'version' ) || defaultArgs . version || VERSION_LATEST ,
1112 accessKey : core . getInput ( 'access-key' ) || defaultArgs . accessKey ,
1213 secretKey : core . getInput ( 'secret-key' ) || defaultArgs . secretKey ,
@@ -29,7 +30,7 @@ export const main = async () => {
2930 return
3031 }
3132
32- const cliPath = await install ( args . version )
33+ const cliPath = await install ( args . version , args . repoToken )
3334
3435 if ( args . args ) {
3536 fillEnv ( args )
Original file line number Diff line number Diff line change @@ -10,9 +10,16 @@ type LatestPayload = {
1010
1111const latestUrl =
1212 'https://api.github.com/repos/scaleway/scaleway-cli/releases/latest'
13- export const getLatest = async ( ) => {
13+ export const getLatest = async ( repoToken : string ) => {
14+ const headers : Record < string , string > = {
15+ Accept : 'application/vnd.github+json' ,
16+ }
17+ if ( repoToken . trim ( ) !== '' ) {
18+ headers . Authorization = `Bearer ${ repoToken } `
19+ }
20+
1421 const httpClient = new HttpClient ( USER_AGENT )
15- const resp = await httpClient . getJson < LatestPayload > ( latestUrl )
22+ const resp = await httpClient . getJson < LatestPayload > ( latestUrl , headers )
1623
1724 if ( resp . statusCode !== 200 ) {
1825 throw new Error (
You can’t perform that action at this time.
0 commit comments