Merge pull request #40 from zharinov/github-auth-token

Support "github-token" parameter
This commit is contained in:
Kirill Chernyshov 2022-02-21 14:59:57 +01:00 committed by GitHub
commit a7463fd4d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 36 additions and 11 deletions

View File

@ -90,6 +90,7 @@ jobs:
uses: ./
with:
lein: 2.9.1
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check leiningen version
run: lein version
@ -117,6 +118,7 @@ jobs:
uses: ./
with:
boot: 2.8.3
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Check boot version
run: boot -V

View File

@ -12,7 +12,11 @@ inputs:
tools-deps:
description: '[DEPRECATED] The tools deps version to make available on the path.'
cli:
description: 'Clojure CLI version to make availablr on the path.'
description: 'Clojure CLI version to make available on the path.'
github-token:
description: >+
To fix rate limit errors, provide `secrets.GITHUB_TOKEN` value to this field.
More info: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
runs:
using: 'node12'
main: 'dist/index.js'

View File

@ -24,7 +24,10 @@ if (!tempDirectory) {
tempDirectory = path.join(baseLocation, 'actions', 'temp')
}
export async function setup(version: string): Promise<void> {
export async function setup(
version: string,
githubAuth?: string
): Promise<void> {
let toolPath = tc.find(
'Boot',
utils.getCacheVersionString(version),
@ -35,7 +38,9 @@ export async function setup(version: string): Promise<void> {
core.info(`Boot found in cache ${toolPath}`)
} else {
const bootBootstrapFile = await tc.downloadTool(
`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh`
`https://github.com/boot-clj/boot-bin/releases/download/latest/boot.sh`,
undefined,
githubAuth
)
const tempDir: string = path.join(
tempDirectory,

View File

@ -9,7 +9,10 @@ import * as utils from './utils'
const tempDirectory = utils.getTempDir()
export async function setup(version: string): Promise<void> {
export async function setup(
version: string,
githubToken?: string
): Promise<void> {
let toolPath = tc.find(
'ClojureToolsDeps',
utils.getCacheVersionString(version),
@ -30,7 +33,7 @@ export async function setup(version: string): Promise<void> {
)
if (utils.isMacOS()) {
await MacOSDeps(clojureInstallScript)
await MacOSDeps(clojureInstallScript, githubToken)
}
const clojureToolsDir = await runLinuxInstall(clojureInstallScript, tempDir)
@ -59,7 +62,7 @@ async function runLinuxInstall(
return destinationFolder
}
async function MacOSDeps(file: string): Promise<void> {
async function MacOSDeps(file: string, githubToken?: string): Promise<void> {
fs.readFile(file, 'utf-8', function (err, data) {
if (err) throw err
@ -72,7 +75,10 @@ async function MacOSDeps(file: string): Promise<void> {
if (e) throw e
})
})
await exec.exec(`brew install coreutils`)
const env = githubToken
? {env: {HOMEBREW_GITHUB_API_TOKEN: githubToken}}
: undefined
await exec.exec('brew', ['install', 'coreutils'], env)
}
export async function setupWindows(version: string): Promise<void> {

View File

@ -10,7 +10,10 @@ import * as utils from './utils'
const tempDirectory = utils.getTempDir()
const IS_WINDOWS = utils.isWindows()
export async function setup(version: string): Promise<void> {
export async function setup(
version: string,
githubAuth?: string
): Promise<void> {
let toolPath = tc.find(
'Leiningen',
utils.getCacheVersionString(version),
@ -23,7 +26,9 @@ export async function setup(version: string): Promise<void> {
const leiningenFile = await tc.downloadTool(
`https://raw.githubusercontent.com/technomancy/leiningen/${
version === 'latest' ? 'stable' : version
}/bin/lein${IS_WINDOWS ? '.ps1' : ''}`
}/bin/lein${IS_WINDOWS ? '.ps1' : ''}`,
undefined,
githubAuth
)
const tempDir: string = path.join(
tempDirectory,

View File

@ -13,15 +13,18 @@ async function run(): Promise<void> {
const TDEPS_VERSION = core.getInput('tools-deps')
const CLI_VERSION = core.getInput('cli')
const githubToken = core.getInput('github-token')
const githubAuth = githubToken ? `token ${githubToken}` : undefined
if (LEIN_VERSION) {
lein.setup(LEIN_VERSION)
lein.setup(LEIN_VERSION, githubAuth)
}
if (BOOT_VERSION) {
if (IS_WINDOWS) {
throw new Error('Boot on windows is not supported yet.')
}
boot.setup(BOOT_VERSION)
boot.setup(BOOT_VERSION, githubAuth)
}
if (CLI_VERSION) {