docs: registries

This commit is contained in:
Jozef Steinhübl 2025-07-08 22:45:44 +02:00
parent 2b1c606e1d
commit b9c0f542fe
No known key found for this signature in database
GPG key ID: E6BC90C91973B08F
4 changed files with 40 additions and 17 deletions

View file

@ -197,7 +197,6 @@ jobs:
- name: Install from default registry
run: |
output=$(bun add is-odd --verbose --force 2>&1)
echo "$output"
if echo "$output" | grep -q "HTTP/1.1 GET https://registry.npmjs.org/is-odd"; then
echo "Successfully installed from default registry"
@ -208,10 +207,9 @@ jobs:
- name: Install from @types registry
run: |
output=$(bun add @types/bun --verbose --force)
echo "$output"
output=$(bun add @types/bun --verbose --force 2>&1)
if echo "$output" | grep -q "HTTP/1.1 GET https://registry.yarnpkg.com/@types/bun"; then
if echo "$output" | grep -q "HTTP/1.1 GET https://registry.yarnpkg.com/@types%2fbun"; then
echo "Successfully installed from @types registry"
else
echo "Failed to install from @types registry"

View file

@ -18,24 +18,39 @@ Download, install, and setup [Bun](https://bun.sh) in GitHub Actions.
bun-version-file: ".bun-version"
```
### Using a custom NPM registry
## Using custom registries
You can configure multiple package registries using the `registries` input. This supports both default and scoped registries with various authentication methods.
### Registry configuration
```yaml
- uses: oven-sh/setup-bun@v2
with:
registry-url: "https://npm.pkg.github.com/"
scope: "@foo"
```
registries: |
https://registry.npmjs.org/
@myorg:https://npm.pkg.github.com/|$GITHUB_TOKEN
@internal:https://username:$INTERNAL_PASSWORD@registry.internal.com/
If you need to authenticate with a private registry, you can set the `BUN_AUTH_TOKEN` environment variable.
```yaml
- name: Install Dependencies
- name: Install dependencies
env:
BUN_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: bun install --frozen-lockfile
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INTERNAL_PASSWORD: ${{ secrets.INTERNAL_PASSWORD }}
run: bun install
```
#### Registry format options
- **Default registry**: `https://registry.npmjs.org/`
- **Default registry with token**: `https://registry.npmjs.org/|$TOKEN`
- **Scoped registry**: `@scope:https://registry.example.com/`
- **Scoped registry with token**: `@scope:https://registry.example.com/|$TOKEN`
- **Scoped registry with URL credentials**: `@scope:https://username:$PASSWORD@registry.example.com/`
> **Note**: When using authentication, make sure to set the corresponding environment variables in your workflow steps that need access to the registries.
For more information about configuring registries in Bun, see the [official documentation](https://bun.sh/docs/install/registries).
### Override download url
If you need to override the download URL, you can use the `bun-download-url` input.

View file

@ -17,15 +17,23 @@ inputs:
bun-download-url:
description: Override the URL to download Bun from. This skips version resolution and verifying AVX2 support.
required: false
registries:
description: |
List of package registries with authentication support. Format:
- Default registry: https://registry.npmjs.org/
- Default with token: https://registry.npmjs.org/|token
- Scoped registry: @scope:https://registry.example.com/
- Scoped with token: @scope:https://registry.example.com/|token
- Scoped with credentials: @scope:https://user:pass@registry.example.com/
required: false
registry-url:
required: false
description: The URL of the package registry to use for installing Bun. Set the $BUN_AUTH_TOKEN environment variable to authenticate with the registry.
deprecationMessage: "Use 'registries' input instead."
scope:
required: false
description: "The scope for authenticating with the package registry."
registries:
required: false
description: "An list of package registries for authenticating with the package registry."
deprecationMessage: "Use 'registries' input instead."
no-cache:
required: false
type: boolean

View file

@ -9,6 +9,8 @@ if (!process.env.RUNNER_TEMP) {
}
const registries = parseRegistries(getInput("registries"));
// Backwards compatibility for the `registry-url` and `scope` inputs
const registryUrl = getInput("registry-url");
const scope = getInput("scope");