Skip to main content

Configuring Dependabot version updates

You can configure your repository so that Dependabot automatically updates the packages you use.

Quem pode usar esse recurso?

Users with write access

About version updates for dependencies

You enable Dependabot version updates by checking a dependabot.yml configuration file in to your repository's .github directory. Dependabot then raises pull requests to keep the dependencies you configure up-to-date. For each package manager's dependencies that you want to update, you must specify the location of the package manifest files and how often to check for updates to the dependencies listed in those files. For information about enabling security updates, see Configuring Dependabot security updates.

Quando você habilitar atualizações de versão pela primeira vez, você pode ter muitas dependências que estão desatualizadas e algumas podem ser muitas versões por trás da versão mais recente. O Dependabot verifica as dependências desatualizadas assim que estiver habilitado. Você pode ver novas pull requests para atualizações de versão dentro de alguns minutos após adicionar o arquivo de configuração, dependendo do número de arquivos de manifesto para os quais você configura as atualizações. Dependabot também será executada uma atualização sobre as alterações subsequentes no arquivo de configuração.

Para manter as solicitações de pull gerenciáveis e fáceis de serem revisadas, o Dependabot gera, no máximo, cinco solicitações de pull para começar a trazer as dependências para a última versão. Se você fizer o merge de algumas desses primeiros pull requests antes da próxima atualização programada, Os pull requests restantes serão abertos na próxima atualização, até o máximo. Você pode alterar o número máximo de solicitações de pull em aberto definindo a opção de configuração open-pull-requests-limit.

Para reduzir ainda mais o número de solicitações de pull que você está vendo, você pode usar a opção de configuração groups para agrupar conjuntos de dependências (por ecossistema de pacote). Em seguida, o Dependabot gera uma única solicitação de pull para atualizar o máximo de dependências possível no grupo para as versões mais recentes ao mesmo tempo. For more information, see Otimizando a criação de pull requests para atualizações de versão do Dependabot.

Ocasionalmente, devido a uma configuração incorreta ou uma versão incompatível, você pode ver que a execução do Dependabot falhou. Após 15 execuções com falha, o Dependabot version updates ignorará as execuções subsequentes agendadas até que você acione manualmente um marcador para atualizações do gráfico de dependência. Dependabot security updates ainda será executado como de costume.

By default only direct dependencies that are explicitly defined in a manifest are kept up to date by Dependabot version updates. You can choose to receive updates for indirect dependencies defined in lock files. For more information, see Controlling which dependencies are updated by Dependabot.

Ao executar atualizações de segurança ou versão, alguns ecossistemas devem ser capazes de resolver todas as dependências de sua fonte para verificar se as atualizações foram bem-sucedidas. Se o seu manifesto ou arquivos de bloqueio contiverem dependências privadas, Dependabot deverá ser capaz de acessar o local em que essas dependências estão hospedadas. Os proprietários da organização podem conceder a Dependabot acesso a repositórios privados que contêm dependências para um projeto dentro da mesma organização. Para saber mais, confira Gerenciando as configurações de segurança e de análise da sua organização. Você pode configurar o acesso a registros privados no arquivo de configuração dependabot.yml de um repositório. Para saber mais, confira Configuring access to private registries for Dependabot. Additionally, Dependabot doesn't support private GitHub dependencies for all package managers. For more information, see Ecossistemas e repositórios compatíveis com o Dependabot and Suporte a linguagem do GitHub.

Enabling Dependabot version updates

You enable Dependabot version updates by committing a dependabot.yml configuration file to your repository. If you enable the feature in your settings page, GitHub creates a basic file which you can edit, otherwise you can create the file using any file editor.

  1. Em GitHub, acesse a página principal do repositório.

  2. No nome do repositório, clique em Settings. Caso não consiga ver a guia "Configurações", selecione o menu suspenso , clique em Configurações.

    Captura de tela de um cabeçalho de repositório que mostra as guias. A guia "Configurações" é realçada por um contorno laranja-escuro.

  3. Na seção "Security" da barra lateral, clique em Advanced Security.

  4. Under "Dependabot", to the right of "Dependabot version updates", click Enable to open a basic dependabot.yml configuration file in the .github directory of your repository. For information about the options you can use to customize how Dependabot maintains your repositories, see Referência de opções do Dependabot.

    YAML
    # To get started with Dependabot version updates, you'll need to specify which
    # package ecosystems to update and where the package manifests are located.
    
    version: 2
    updates:
    - package-ecosystem: "" # See documentation for possible values
      directory: "/" # Location of package manifests
      schedule:
        interval: "weekly"
    
  5. Add a version. This key is mandatory. The file must start with version: 2.

  6. Optionally, if you have dependencies in a private registry, add a registries section containing authentication details. For more information, see Configuring access to private registries for Dependabot.

  7. Add an updates section, with an entry for each package manager you want Dependabot to monitor. This key is mandatory. You use it to configure how Dependabot updates the versions or your project's dependencies. Each entry configures the update settings for a particular package manager. For more information, see About the dependabot.yml file in "Dependabot options reference."

  8. For each package manager, use:

    • package-ecosystem to specify the package manager. For more information about the supported package managers, see package-ecosystem.
    • directories or directory to specify the location of multiple manifest or other definition files. For more information, see Defining multiple locations for manifest files.
    • schedule.interval to specify how often to check for new versions.
  9. Verifique o arquivo de configuração dependabot.yml no diretório .github do repositório.

Example dependabot.yml file

The example dependabot.yml file below configures version updates for three package managers: npm, Docker, and GitHub Actions. When this file is checked in, Dependabot checks the manifest files on the default branch for outdated dependencies. If it finds outdated dependencies, it will raise pull requests against the default branch to update the dependencies.

YAML
# Basic `dependabot.yml` file with
# minimum configuration for three package managers

version: 2
updates:
  # Enable version updates for npm
  - package-ecosystem: "npm"
    # Look for `package.json` and `lock` files in the `root` directory
    directory: "/"
    # Check the npm registry for updates every day (weekdays)
    schedule:
      interval: "daily"

  # Enable version updates for Docker
  - package-ecosystem: "docker"
    # Look for a `Dockerfile` in the `root` directory
    directory: "/"
    # Check for updates once a week
    schedule:
      interval: "weekly"

  # Enable version updates for GitHub Actions
  - package-ecosystem: "github-actions"
    # Workflow files stored in the default location of `.github/workflows`
    # You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.
    directory: "/"
    schedule:
      interval: "weekly"

In the example above, if the Docker dependencies were very outdated, you might want to start with a daily schedule until the dependencies are up-to-date, and then drop back to a weekly schedule.

Enabling version updates on forks

If you want to enable version updates on forks, there's an extra step. Version updates are not automatically enabled on forks when a dependabot.yml configuration file is present. This ensures that fork owners don't unintentionally enable version updates when they pull changes including a dependabot.yml configuration file from the original repository.

On a fork, you also need to explicitly enable Dependabot.

  1. Em GitHub, acesse a página principal do repositório.

  2. No nome do repositório, clique em Settings. Caso não consiga ver a guia "Configurações", selecione o menu suspenso , clique em Configurações.

    Captura de tela de um cabeçalho de repositório que mostra as guias. A guia "Configurações" é realçada por um contorno laranja-escuro.

  3. Na seção "Security" da barra lateral, clique em Advanced Security.

  4. Under "Dependabot," to the right of "Dependabot version updates," click Enable to allow Dependabot to initiate version updates.

Checking the status of version updates

After you enable version updates, the Dependabot tab in the dependency graph for the repository is populated. This tab shows which package managers Dependabot is configured to monitor and when Dependabot last checked for new versions.

Screenshot of the Dependency graph page. A tab, titled "Dependabot," is highlighted with an orange outline.

For information, see Listing dependencies configured for version updates.

Disabling Dependabot version updates

You can disable version updates entirely by deleting the dependabot.yml file from your repository. More usually, you want to disable updates temporarily for one or more dependencies, or package managers.

  • Package managers: disable by setting open-pull-requests-limit: 0 or by commenting out the relevant package-ecosystem in the configuration file.
  • Specific dependencies: disable by adding ignore attributes for packages or applications that you want to exclude from updates.

When you disable dependencies, you can use wild cards to match a set of related libraries. You can also specify which versions to exclude. This is particularly useful if you need to block updates to a library, pending work to support a breaking change to its API, but want to get any security fixes to the version you use.

Example disabling version updates for some dependencies

The example dependabot.yml file below includes examples of the different ways to disable updates to some dependencies, while allowing other updates to continue.

# `dependabot.yml` file with updates
# disabled for Docker and limited for npm

version: 2
updates:
  # Configuration for Dockerfile
  - package-ecosystem: "docker"
    directory: "/"
    schedule:
      interval: "weekly"
      # Disable all pull requests for Docker dependencies
    open-pull-requests-limit: 0

  # Configuration for npm
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    ignore:
      # Ignore updates to packages that start with 'aws'
      # Wildcards match zero or more arbitrary characters
      - dependency-name: "aws*"
      # Ignore some updates to the 'express' package
      - dependency-name: "express"
        # Ignore only new versions for 4.x and 5.x
        versions: ["4.x", "5.x"]
      # For all packages, ignore all patch updates
      - dependency-name: "*"
        update-types: ["version-update:semver-patch"]

For more information about checking for existing ignore preferences, see Referência de opções do Dependabot.