gradle/gradle-build-action: Run Gradle with Caching
gradle-build-action runs Gradle with automatic dependency and build caching.
It configures Gradle, restores and saves caches, and reports build results. Newer projects use gradle/actions/setup-gradle, which shares the same caching engine.
Key inputs (with:)
- arguments: the Gradle tasks and flags to run.
- gradle-version: pin a Gradle version.
- cache-read-only: avoid writing cache on non-default branches.
- build-scan-publish: publish a build scan.
Example workflow
.github/workflows/ci.yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '21'
- uses: gradle/gradle-build-action@v3
with:
arguments: buildOn any runner
This action runs on any runner. Latchkey managed runners run it unchanged.
Key takeaways
- Handles Gradle dependency and build caching for you.
- Newer setups use gradle/actions/setup-gradle.
- Pair it with setup-java for the JDK.
Related guides
actions/setup-java: Install the JDK in CIReference for actions/setup-java: choose a JDK distribution and version, cache Maven or Gradle, and configure…
actions/cache: Save & Restore Build CachesReference for actions/cache: cache dependencies and build outputs across runs using key and restore-keys, wit…
actions/checkout: Inputs & Workflow UsageReference for actions/checkout: clone your repository into the runner, control fetch-depth, submodules, refs,…