Mirror of bazel-contrib/setup-bazel for self-hosted Forgejo Actions
Find a file
renovate[bot] c9a2a71272
fix(deps): update dependency @actions/glob to ^0.6.0 (#142)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2026-02-05 21:37:59 -08:00
.github/workflows Update actions/checkout action to v6 (#109) 2025-12-04 07:14:46 -08:00
dist Release 0.18.0 2026-01-11 16:34:54 +00:00
.gitignore Hello world 2023-01-04 16:31:00 -08:00
.tool-versions chore(deps): update node.js to v24.13.0 (#132) 2026-01-14 18:30:30 -08:00
action.yml Add post-if !cancelled() condition (#128) 2026-01-11 08:33:54 -08:00
config.js allow saving cache to be optional (#131) 2026-01-11 08:30:32 -08:00
index.js fix: add logging when failing to restore cache (#127) 2026-01-08 11:48:02 -08:00
LICENSE Initial commit 2023-01-04 16:27:56 -08:00
package-lock.json fix(deps): update dependency @actions/glob to ^0.6.0 (#142) 2026-02-05 21:37:59 -08:00
package.json fix(deps): update dependency @actions/glob to ^0.6.0 (#142) 2026-02-05 21:37:59 -08:00
post.js allow saving cache to be optional (#131) 2026-01-11 08:30:32 -08:00
README.md Release 0.18.0 2026-01-11 16:34:54 +00:00
renovate.json Add renovate.json (#3) 2024-03-09 11:06:24 -08:00
util.js Fix regression in gathering folder size 2023-11-26 17:11:31 -08:00

setup-bazel

This action allows to properly configure Bazelisk and Bazel on all operating systems and provides an advanced fine-grained caching to improve workflows performance.

Usage

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    # Avoid downloading Bazel every time.
    bazelisk-cache: true
    # Store build cache per workflow.
    disk-cache: ${{ github.workflow }}
    # Share repository cache between workflows.
    repository-cache: true

Inputs

bazelisk-cache

Cache bazelisk downloads based on contents of a .bazelversion file.

Default false.

bazelisk-version

bazelisk version to download and use.

Supports semver specification and ranges. Leave empty to use pre-installed Bazelisk.

Default "".

Examples

Install Bazelisk 1.x

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    bazelisk-version: 1.x

Install exact Bazelisk version

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    bazelisk-version: 1.19.0

bazelrc

Extra contents to write to a user's bazelrc file.

You can use multiline YAML strings.

Default "".

Examples

Enable Bzlmod

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    bazelrc: common --enable_bzlmod

Add colors and timestamps

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    bazelrc: |
      build --color=yes
      build --show_timestamps

cache-save

Whether to save caches at the end of the workflow.

Set to false for pull requests to allow cache restoration without saving, which prevents PRs from polluting the cache while still benefiting from it.

Default true.

Examples

Disable cache saving on pull requests

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    bazelisk-cache: true
    disk-cache: ${{ github.workflow }}
    repository-cache: true
    cache-save: ${{ github.event_name != 'pull_request' }}

disk-cache

Enable disk_cache and store it on GitHub based on contents of BUILD files.

You can also pass a string to use as a cache key to separate caches from different workflows.

Default false.

Examples

Share a single disk cache

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    disk-cache: true

Separate disk caches between workflows

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    disk-cache: ${{ github.workflow }}}

external-cache

Cache external/ repositories based on contents of MODULE.bazel and WORKSPACE files. Only repositories exceeding 10MB are being cached. Each repository is stored in a separate cache.

You can also pass a manifest object where key is the name of the external repository and value is a file (or list of files) which contents are used to calculate cache key. If the value is false, the external repository won't be cached.

Default false.

Examples

Enable external repositories caches

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    external-cache: true

Cache NPM repositories based on package-lock.json contents

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    external-cache: |
      manifest:
        npm: package-lock.json

Do not cache Ruby on Windows

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    external-cache: |
      manifest:
        ruby: ${{ runner.os == 'Windows' && 'false' || 'true' }}

google-credentials

Google Cloud account key to use for remote caching authentication.

Default "".

Examples

Authenticate via key

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    google-credentials: ${{ secrets.GOOGLE_CLOUD_KEY }}

module-root

Bazel module root directory, where MODULE.bazel and WORKSPACE is found.

Change this value to the module root if it's not the repository root.

Default ".".

output-base

Change Bazel output base directory.

You might want to change it when running on self-hosted runners with a custom directory layout.

Default is one of the following:

  • $HOME/.bazel on Linux and macOS
  • D:/_bazel on Windows
Examples

Use C drive letter

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    output-base: C:/_bazel

repository-cache

Enable repository_cache and store it on GitHub based on contents of MODULE.bazel and WORKSPACE files.

You can also pass a file (or list of files) which contents are used to calculate cache key.

Default false.

Examples

Store a single repository cache

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    repository-cache: true

Store a repository cache from a custom location

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    repository-cache: examples/gem/WORKSPACE

Store a repository cache from a list of custom locations

- uses: bazel-contrib/setup-bazel@0.18.0
  with:
    repository-cache: |
      - MODULE.bazel
      - requirements_locked.txt

Migrating from bazelbuild/setup-bazelisk

You can simply replace bazelbuild/setup-bazelisk action with bazel-contrib/setup-bazel. However, if you used a bazel-version input before, you will need to remove it in favor other ways to specify Bazel version.

Development

To build action, run the following command:

$ npm install
$ npm run build

Release

Use Release workflow to cut a new release.