Skip to content

Commit e349d57

Browse files
authoredApr 11, 2023
Allow configuring the buf remote (#121)
Add an input to the setup action that can control which Buf Schema Registry to login to, which will be useful for users who have a private BSR instance. I used `domain` as this is what we refer to in the cli help: ``` $ buf registry login --help Log in to the Buf Schema Registry This prompts for your BSR username and a BSR token and updates your .netrc file with these credentials. The <domain> argument will default to buf.build if not specified. Usage: buf registry login <domain> [flags] ```
1 parent 2bd6541 commit e349d57

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed
 

‎README.md

+7
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ You can configure `buf-setup-action` with these parameters:
3636
| `github_token` | The GitHub token to use when making API requests | |
3737
| `buf_user` | The username to use for logging into Buf Schema registry. | |
3838
| `buf_api_token` | The API token to use for logging into Buf Schema registry. | |
39+
| `buf_domain` | The domain of the Buf Schema Registry to login to. | buf.build |
3940

4041
> These parameters are derived from [`action.yml`](./action.yml). <br>
4142
#### Version
@@ -117,6 +118,12 @@ Note that this only authenticate you with the `buf` cli. You cannot access your
117118
packages in BSR. If you need to access your private remote packages, supply the username and Buf
118119
API Token [as parameters](#buf-username-and-buf-api-token).
119120

121+
#### Buf domain
122+
123+
If you are working with a private BSR then you can set the `buf_domain` input to the domain of
124+
your instance. Please ensure that you are using a token created on your instance (e.g. `https://buf.example.com/settings/user`) and not from the public BSR at `https://buf.build`.
125+
126+
120127
#### Installing `protoc`
121128

122129
In most cases, you _don't_ need to install [`protoc`][protoc] for Buf's GitHub Actions, but some

‎action.yml

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ inputs:
1818
buf_api_token:
1919
description: The API token to use for logging into Buf Schema registry.
2020
required: false
21+
buf_domain:
22+
description: The domain of the Buf Schema Registry to login to.
23+
required: false
24+
default: 'buf.build'
2125
runs:
2226
using: "node16"
2327
main: "./dist/main.js"

‎dist/main.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎dist/main.js.map

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎src/run.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,15 @@ async function runSetup(): Promise<null | Error> {
7979
core.info(`Successfully setup buf version ${version}`);
8080
core.info(cp.execSync(`${binaryPath} --version`).toString());
8181

82+
const bufDomain = core.getInput("buf_domain");
8283
const bufUser = core.getInput("buf_user");
8384
const bufAPIToken = core.getInput("buf_api_token");
8485
if (bufUser !== "" && bufAPIToken !== "") {
8586
core.info(`buf_user and buf_token supplied, logging in...`);
8687
core.info(
8788
cp
8889
.execSync(
89-
`${binaryPath} registry login --username ${bufUser} --token-stdin`,
90+
`${binaryPath} registry login ${bufDomain} --username ${bufUser} --token-stdin`,
9091
{ input: bufAPIToken }
9192
)
9293
.toString()

0 commit comments

Comments
 (0)
Please sign in to comment.