mirror of
https://github.com/DeLaGuardo/setup-clojure.git
synced 2025-01-14 10:27:55 +08:00
Merge pull request #40 from zharinov/github-auth-token
Support "github-token" parameter
This commit is contained in:
commit
a7463fd4d6
2
.github/workflows/smoke-tests.yml
vendored
2
.github/workflows/smoke-tests.yml
vendored
@ -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
|
||||
|
@ -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'
|
||||
|
@ -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,
|
||||
|
14
src/cli.ts
14
src/cli.ts
@ -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> {
|
||||
|
@ -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,
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user