Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom repository variables #631

Merged
merged 3 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
8 changes: 8 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
17 changes: 17 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,23 @@ async function cs(...args: string[]): Promise<string> {
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)
}

Expand Down