Skip to content

Set up Dependabot for the GitHub Actions, the Gradle dependencies and the Gradle wrapper #2100

Open

Description

@lagergren

What

Let Dependabot open pull requests when a new version is out of:

  • a GitHub Action of .github/workflows;
  • a library or Gradle plugin of the build, as those of gradle/libs.versions.toml;
  • the Gradle wrapper.

Today nothing tells us, and the versions are upgraded by hand.

What we have today

  • No .github/dependabot.yml, and no pull request has ever come from Dependabot.
  • Dependabot alerts are on. There have been 6, all for gradle/gradle-build-action (GHSA-h3qr-39j9-4r5v), opened in 2023-11 and fixed in 2024-03. None is open.
  • The alerts only see the GitHub Actions. The dependency graph of the repository has 10 actions and no Gradle dependency, so a vulnerable LSP4J, flexmark or Gradle plugin would raise no alert. GitHub doesn't read a Gradle build by itself: the build has to submit its dependencies.
  • Two of the libraries are out of Dependabot's sight:
    • build.gradle.kts reads the versions of LSP4J and flexmark from gradle.properties, with prop("lsp4jVersion") and prop("flexmarkVersion");
    • Dependabot reads the build files without running them, and its docs don't say that it resolves a value read through a function like that;
    • those two are the libraries that the plugin bundles, so they matter most for security.
  • The wrapper's version is held in two places: in gradle-wrapper.properties, and as gradleVersion in gradle.properties, which the wrapper task of build.gradle.kts reads. A wrapper update by Dependabot changes only the first. The next ./gradlew wrapper would then go back to the old version.

What it takes

1. A pull request, which anyone with write access can merge

Committing .github/dependabot.yml is what turns on version updates (docs). No setting needs an admin.

The pull request would:

a. Move the versions of LSP4J and flexmark into gradle/libs.versions.toml, with their libraries, and use libs.… in build.gradle.kts. Do the same for junit-platform-launcher, which build.gradle.kts sets to 1.11.0 itself. Dependabot supports the version catalog gradle/libs.versions.toml (docs).

b. Drop gradleVersion from gradle.properties and from the wrapper task. Without it, ./gradlew wrapper keeps the version that runs it, which is the one of gradle-wrapper.properties. The task keeps its networkTimeout and its retries. Dependabot updates the wrapper within the gradle ecosystem: gradle-wrapper.properties, gradlew, gradlew.bat and gradle-wrapper.jar.

c. Add .github/dependabot.yml:

version: 2
updates:
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"
    # "ci(deps): bump …", which the pull request title check accepts, and which the release notes leave out
    commit-message:
      prefix: "ci"
      include: "scope"
    labels:
      - "build"
    groups:
      github-actions:
        patterns:
          - "*"

  - package-ecosystem: "gradle"
    directory: "/"
    schedule:
      interval: "weekly"
    # "build(deps): bump …", which the release notes list under Build
    commit-message:
      prefix: "build"
      include: "scope"
    labels:
      - "build"
    ignore:
      # Kotlin 2.4 no longer accepts apiVersion/languageVersion 1.9, which the plugin needs while pluginSinceBuild is
      # 242: see gradle/libs.versions.toml
      - dependency-name: "org.jetbrains.kotlin.jvm"
        versions: [">= 2.4"]
    groups:
      # One pull request a week for the minor and patch versions; a major version gets a pull request of its own
      gradle-minor-and-patch:
        update-types:
          - "minor"
          - "patch"

Notes on it:

  • The pull request title check (amannn/action-semantic-pull-request) needs a Conventional Commits title. Dependabot's own title, Bump x from 1 to 2, would fail it, so the config sets the prefix to ci or build, with the deps scope.
  • The release notes take build commits under "Build" and leave out ci ones. A grouped update reads "bump the gradle-minor-and-patch group with 3 updates", and the commit body lists the versions.
  • Labels: without labels, Dependabot creates and adds dependencies and java or github_actions. With labels, it adds the repository's own build label instead.
  • Groups keep the pull requests few. Each push to a pull request starts 4 workflows, and CodeRabbit reviews 2 pull requests an hour.
  • Actions pinned by commit SHA, as amannn/action-semantic-pull-request@d2ab… #v3.1.0: Dependabot updates the SHA and the version comment that follows it on the same line.
  • The name of the Kotlin plugin in ignore: Dependabot's docs give groupId:artifactId for Gradle dependencies, and don't say how they name a plugin of the version catalog. To check on its first run: if a pull request offers Kotlin 2.4, use the name that it gives.
  • .github/workflows/itests.yml.disabled isn't a .yml file, so Dependabot doesn't read it.
  • CI on its pull requests: a workflow that a Dependabot pull request starts gets a read-only GITHUB_TOKEN and no Actions secrets (docs). The pull request workflows (ci.yml, IJ.yml, buildZip.yml, conventionalCheck.yml) use no secret but the GITHUB_TOKEN, so they run as for any pull request.

2. A second pull request, for alerts on the Gradle dependencies (recommended)

Add a workflow that submits the dependencies of the Gradle build to the dependency graph, with gradle/actions/dependency-submission, on each push to main. Use 6.4.1 or later, pinned by SHA: GHSA-chpw-2mqm-95cc (high) affects dependency-submission up to 6.4.0. In v6, the caching of gradle/actions comes under Gradle's Terms of Use unless cache-provider: basic is set (see #2103). The repository already uses gradle/actions/setup-gradle from the same repository. The job needs permissions: contents: write. After it runs once, Dependabot alerts cover LSP4J, flexmark and the other libraries, as they cover the actions today.

3. Needs an admin of the repository (optional)

Dependabot security updates open a pull request as soon as an alert has a fixed version, without waiting for the weekly run. An admin turns them on in Settings › Advanced Security › Dependabot security updates (docs).

@angelozerr, this is the only step that needs you, as an admin. Steps 1 and 2 are pull requests. Would you like security updates on?

Not covered

Activity

  1. added
    enhancement
    on Nov 22, 2026
  2. added this to the Backlog milestone on Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buildenhancement

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions