Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
arrow-up

GitHub Action

buf-push

v1.0.0

buf-push

arrow-up

buf-push

Push buf module updates to the Buf Schema Registry.

Installation

Copy and paste the following snippet into your .yml file.

              

- name: buf-push

uses: bufbuild/[email protected]

Learn more about this action in bufbuild/buf-push-action

Choose a version

buf-push-action

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.

Usage

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.

Basic

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 }}

Inputs

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 }}

Validate before push

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 }}