GitHub Action
buf-push
Push buf modules to the Buf Schema Registry (BSR). The pushed module will be created with a module tag equal to the git commit SHA.
Refer to the action.yml to see all of the action parameters.
The buf-push
action requires that buf
is installed in the Github Action
runner, so we'll use the buf-setup action to install it.
In most cases, all you'll need to do is configure buf-setup and the
buf_token
(used to authenticate access to the BSR). For details on
creating a buf
API token, please refer to the
documentation.
Once you've created a buf
API token, you'll need to create an encrypted
Github Secret
for it. In the following example, the API token is set to BUF_TOKEN
.
steps:
- uses: actions/checkout@v2
- uses: bufbuild/[email protected]
- uses: bufbuild/[email protected]
with:
buf_token: ${{ secrets.BUF_TOKEN }}
Some repositories are structured so that their buf.yaml
is defined
in a sub-directory alongside their Protobuf sources, such as a proto/
directory. In this case, you can specify the relative input
path.
$ tree
.
└── proto
├── acme
│ └── weather
│ └── v1
│ └── weather.proto
└── buf.yaml
steps:
- uses: actions/checkout@v2
- uses: bufbuild/[email protected]
- uses: bufbuild/[email protected]
with:
input: 'proto'
buf_token: ${{ secrets.BUF_TOKEN }}
The buf-push
action is also commonly used alongside other buf
actions,
such as buf-breaking and buf-lint.
In combination, you can verify that your module passes both buf-lint
and buf-breaking
before the module is pushed to the BSR. The following example
uses the hypothetical https://github.com/acme/weather.git
repository.
on:
push:
branches:
- main
jobs:
validate-and-push-protos:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: bufbuild/[email protected]
- uses: bufbuild/[email protected]
with:
input: 'proto'
- uses: bufbuild/[email protected]
with:
input: 'proto'
against: 'https://github.com/acme/weather.git#branch=master,ref=HEAD~1,subdir=proto'
- uses: bufbuild/[email protected]
with:
input: 'proto'
buf_token: ${{ secrets.BUF_TOKEN }}