From b29142d50dc8fe4441fd1678e197a3e9f36fef19 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Wed, 14 Aug 2024 17:22:37 +0200 Subject: [PATCH 1/3] Allow using custom repositories --- action.yml | 8 ++++++++ src/main.ts | 17 +++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/action.yml b/action.yml index 87cc8f7f..1e8510ac 100644 --- a/action.yml +++ b/action.yml @@ -21,6 +21,14 @@ inputs: description: 'Coursier version to install' required: false default: '' + customRepositories: + description: 'The pipe (|) seperated locations of non-standard repositories. See https://get-coursier.io/docs/other-repositories' + required: false + default: '' + disableDefaultRepos: + description: 'Whether to pass the --no-default flag to coursier' + required: false + default: 'false' outputs: cs-version: description: 'Version of the installed Coursier' diff --git a/src/main.ts b/src/main.ts index f4fe1ea0..bbc30691 100644 --- a/src/main.ts +++ b/src/main.ts @@ -95,6 +95,23 @@ async function cs(...args: string[]): Promise { const csCached = await tc.cacheFile(csBinary, binaryName, 'cs', csVersion) core.addPath(csCached) } + + const disableDefaultReposInput = core.getInput('disableDefaultRepos') + + if (disableDefaultReposInput.toLowerCase() === 'true') { + args.push('--no-default') + } + + const customRepositoryInput = core.getInput('customRepositories') + if (customRepositoryInput) { + const repositories = customRepositoryInput.split('|') + + // For each repository, push the `-r` flag and the repository itself to the args list + repositories.forEach(repo => { + args.push('-r', repo.trim()) + }) + } + return execOutput('cs', ...args) } From 9b84392e53e6620168568653b452695787e6e2a6 Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Wed, 14 Aug 2024 17:27:04 +0200 Subject: [PATCH 2/3] update readme --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 295348c0..8c5554df 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,12 @@ Inspired by [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) and - `apps` (optional): Scala apps to install (`sbtn` by default) - space separated list of app names (from the [main channel](https://github.com/coursier/apps)) +- `customRepositories` (optional): '' + - Pipe separated list of [repositories](https://get-coursier.io/docs/other-repositories) to supply to coursier + +- `disableDefaultRepos` (optional): 'false' + - Whether or not to pass the --no-default flag to coursier + ### Example with custom inputs ```yml @@ -36,6 +42,8 @@ Inspired by [olafurpg/setup-scala](https://github.com/olafurpg/setup-scala) and jvm: adopt:11 jvm-index: https://url/of/your/index.json apps: sbtn bloop ammonite + disableDefaultRepos: true + customRepositories: https://packages.corp.com/maven ``` ## Outputs From 330ace0b36a0b210464306ee10754f191e23effc Mon Sep 17 00:00:00 2001 From: Simon Parten Date: Wed, 14 Aug 2024 20:41:23 +0200 Subject: [PATCH 3/3] whitespace --- src/main.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.ts b/src/main.ts index bbc30691..5effdbb6 100644 --- a/src/main.ts +++ b/src/main.ts @@ -95,7 +95,7 @@ async function cs(...args: string[]): Promise { const csCached = await tc.cacheFile(csBinary, binaryName, 'cs', csVersion) core.addPath(csCached) } - + const disableDefaultReposInput = core.getInput('disableDefaultRepos') if (disableDefaultReposInput.toLowerCase() === 'true') {