Skip to main content

CI/CD and automation · Beginner · 16 min

Configure Dependabot version and security updates

By Padding · Updated 18 Nov 2026
GitHub Dependabot · check-jsonschema 0.39.0 · Ubuntu 26.04

You will turn on Dependabot alerts and security updates for a repository and commit a validated dependabot.yml that updates npm, GitHub Actions and Docker weekly, in groups, with a held-back major version, a cooldown, pull request limits and a private registry token kept in Dependabot's own secrets.

On this page

Dependabot is the dependency bot built into GitHub. It does two separate jobs, and it helps to keep them apart in your head:

  • Security updates react to advisories. When GitHub raises a Dependabot alert for a vulnerable package in your repository, Dependabot opens a pull request that moves it to the nearest fixed version. You switch this on in the repository settings; no file is needed.
  • Version updates keep everything current on a schedule, whether or not there is an advisory. These are driven by a file you commit, .github/dependabot.yml.

Left on its defaults, version updates can flood a busy repository with one pull request per package. In this tutorial you set up both jobs for a small Node.js service called shop-web that has npm packages, a GitHub Actions workflow and a Dockerfile, and you shape the version updates so they arrive as a few reviewable pull requests a week. You validate every version of the file before you push it, because Dependabot only reports a broken file after the fact.

Everything lives in ~/dependabot-demo on your computer. Wherever you see YOUR-ORG, replace it with your GitHub user or organisation name.

Step 1 · Create the example repository and the validator

Install Git and Python's virtual environment module, then install check-jsonschema 0.39.0 into its own environment. It carries a copy of the published schema for dependabot.yml, so it can tell you about a misspelt key or an out-of-range value without contacting GitHub.

Bash
sudo apt update
sudo apt install -y git python3-venv
mkdir -p ~/dependabot-demo
python3 -m venv ~/dependabot-demo/tools
~/dependabot-demo/tools/bin/pip install "check-jsonschema==0.39.0"
export PATH="$HOME/dependabot-demo/tools/bin:$PATH"

On macOS, skip the two apt lines; python3 -m venv is already available. The export line only lasts for this terminal, so run it again if you open a new one.

Now create the project. It has one production dependency, two development dependencies, a CI workflow that uses two actions, and a Dockerfile with a base image: one of each of the three ecosystems Dependabot will look after.

Bash
mkdir -p ~/dependabot-demo/shop-web/.github/workflows
cd ~/dependabot-demo/shop-web
git init
cat > package.json <<'JSON'
{
  "name": "shop-web",
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "scripts": {
    "start": "node server.js",
    "lint": "eslint .",
    "format": "prettier --check ."
  },
  "dependencies": {
    "express": "^5.1.0"
  },
  "devDependencies": {
    "eslint": "^9.30.0",
    "prettier": "^3.6.0"
  }
}
JSON
cat > server.js <<'JS'
import express from 'express';

const app = express();
app.get('/', (req, res) => res.send('shop-web is running'));
app.listen(process.env.PORT || 3000);
JS
cat > eslint.config.js <<'JS'
export default [{ files: ['**/*.js'], languageOptions: { sourceType: 'module' } }];
JS
cat > Dockerfile <<'DOCKER'
FROM node:26-slim
WORKDIR /app
COPY package.json ./
RUN npm install --omit=dev
COPY server.js ./
CMD ["node", "server.js"]
DOCKER
cat > .github/workflows/ci.yml <<'YAML'
name: CI
on:
  pull_request:
  push:
    branches: [main]
permissions:
  contents: read
jobs:
  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
        with:
          persist-credentials: false
      - uses: actions/setup-node@v7
        with:
          node-version: '26'
      - run: npm install
      - run: npm run lint
YAML
printf 'node_modules/\n' > .gitignore
git add .
git commit -m "Start shop-web"

eslint.config.js is there because ESLint 9 stops with an error when it finds no flat config file, which would fail CI on every run. In a real project you would also commit package-lock.json. Dependabot updates the lock file alongside package.json when one is there.

Check it worked

Bash
check-jsonschema --version
cd ~/dependabot-demo/shop-web
git log --oneline
ls -A

The first line names version 0.39.0, git log shows one commit, and the listing shows .git, .github, .gitignore, Dockerfile, eslint.config.js, package.json and server.js.

Step 2 · Turn on alerts and security updates

Create an empty repository called shop-web under YOUR-ORG on GitHub, then push:

Bash
cd ~/dependabot-demo/shop-web
git remote add origin git@github.com:YOUR-ORG/shop-web.git
git push -u origin main

In the repository on GitHub, open Settings. In the Security part of the sidebar, open Advanced Security (some accounts still label it Code security). Then:

  1. Make sure the Dependency graph is on. It is on by default for public repositories; private ones may need it turning on. Alerts are built from it.
  2. Next to Dependabot alerts, choose Enable.
  3. Next to Dependabot security updates, choose Enable.

If you prefer the command line, the GitHub CLI calls the same switches through the REST API:

Bash
gh api --method PUT repos/YOUR-ORG/shop-web/vulnerability-alerts
gh api --method PUT repos/YOUR-ORG/shop-web/automated-security-fixes

Leave Grouped security updates alone for now. You will set grouping in dependabot.yml, and the file's group rules take precedence over that toggle. An organisation or enterprise policy can also lock these settings; if the buttons are greyed out, ask an organisation owner.

Check it worked

Bash
gh api repos/YOUR-ORG/shop-web/automated-security-fixes

It prints something like {"enabled":true,"paused":false}. In the browser, the repository's Security tab now lists Dependabot in its sidebar. With these packages there may be no alerts at all, which is fine: security updates only start work when an alert exists.

Step 3 · Write a first dependabot.yml for three ecosystems

Version updates need one entry under updates for each package manager and folder. Start with the smallest useful file: npm, GitHub Actions and Docker, each checked weekly on Monday morning in your own time zone.

Bash
cd ~/dependabot-demo/shop-web
cat > .github/dependabot.yml <<'YAML'
version: 2
updates:
  - package-ecosystem: npm
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos

  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos

  - package-ecosystem: docker
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
YAML

What each part does:

  • version: 2 is the only syntax version; leave it as is.
  • package-ecosystem names the package manager. npm reads package.json (and covers Yarn and pnpm lock files as well), github-actions reads the uses: lines in your workflows, and docker reads FROM lines in Dockerfiles.
  • directory is where the manifest lives, relative to the repository root. For GitHub Actions it is always /; Dependabot finds .github/workflows from there. A monorepo can use directories: with a list or a glob such as /services/* instead.
  • schedule sets how often Dependabot checks. time is read as UTC unless you set timezone, which takes an IANA name. Replace Africa/Lagos with yours, for example Africa/Nairobi or Europe/London. Leave time out and GitHub picks a random time for you.

A Monday morning run means the week's update pull requests are waiting when the team starts, rather than arriving one by one through the weekend.

Check it worked

Bash
cd ~/dependabot-demo/shop-web
check-jsonschema --builtin-schema vendor.dependabot .github/dependabot.yml | tee check.txt
grep -q 'ok -- validation done' check.txt
rm check.txt

It prints ok -- validation done. Try changing interval: weekly to interval: weekley and run the check again: it fails with an error that names something like $.updates[0].schedule.interval. Change it back before you continue.

Step 4 · Group related updates

Without groups, a week with eight new package versions means eight pull requests and eight CI runs. Groups combine matching updates into one pull request each. Replace the file with this version:

Bash
cd ~/dependabot-demo/shop-web
cat > .github/dependabot.yml <<'YAML'
version: 2
updates:
  - package-ecosystem: npm
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    groups:
      # Tooling that never ships to users: minor and patch bumps in one PR.
      npm-dev:
        dependency-type: development
        update-types: [minor, patch]
      # Runtime packages: minor and patch bumps in a second PR.
      npm-prod:
        dependency-type: production
        update-types: [minor, patch]
      # Security fixes for npm arrive together instead of one PR per advisory.
      npm-security:
        applies-to: security-updates
        patterns: ['*']

  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    groups:
      actions:
        patterns: ['*']

  - package-ecosystem: docker
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
YAML

How the groups divide the work:

  • npm-dev and npm-prod split by dependency-type, so a pull request that only touches build tools is clearly separate from one that changes what runs in production. Both list only minor and patch, which means major updates are left out of every group and still arrive as single pull requests. That is deliberate: a major version can break things and deserves its own review.
  • npm-security uses applies-to: security-updates. Groups apply to version updates unless you say otherwise, so without this line security fixes would still come one per package.
  • actions puts every action bump into one pull request. Action updates rarely conflict with each other, and the CI run on that pull request tests them all together.
  • Docker has a single base image here, so a group would add nothing.

Group names appear in pull request titles and branch names. Start and end each one with a letter, and use only letters, hyphens and underscores in between. You can also select packages by name with patterns and exclude-patterns, for example patterns: ['@types/*'] to bundle type definitions.

Check it worked

Bash
cd ~/dependabot-demo/shop-web
check-jsonschema --builtin-schema vendor.dependabot .github/dependabot.yml | tee check.txt
grep -q 'ok -- validation done' check.txt
rm check.txt

It prints ok -- validation done. Read the npm block once more and answer for yourself: where would an update from prettier 3.6 to 3.7 go, and where would express 5 to 6 go? (The first lands in npm-dev; the second is a pull request of its own.)

Step 5 · Hold back a major version, add a cooldown and limit open pull requests

Three more controls make the flow calmer:

  • ignore stops Dependabot proposing something you have decided against for now. Here the team is not ready for the next major version of Express, so major Express updates are ignored while minor and patch updates still come through.
  • cooldown makes Dependabot wait a number of days after a release before proposing it. Brand-new releases are the ones most likely to be pulled, patched again within days, or, occasionally, compromised. The wait applies to version updates only; security updates are never delayed.
  • open-pull-requests-limit caps how many version update pull requests can be open at once for that ecosystem. The default is 5. Security update pull requests have their own fixed limit of 10 and are not affected by this setting.

Replace the file again:

Bash
cd ~/dependabot-demo/shop-web
cat > .github/dependabot.yml <<'YAML'
version: 2
updates:
  - package-ecosystem: npm
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    open-pull-requests-limit: 4
    cooldown:
      default-days: 5
      semver-major-days: 30
      semver-minor-days: 7
      semver-patch-days: 3
    ignore:
      # Express 6 needs a planned migration. Review this rule each quarter.
      - dependency-name: express
        update-types: ['version-update:semver-major']
    groups:
      npm-dev:
        dependency-type: development
        update-types: [minor, patch]
      npm-prod:
        dependency-type: production
        update-types: [minor, patch]
      npm-security:
        applies-to: security-updates
        patterns: ['*']

  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    open-pull-requests-limit: 2
    cooldown:
      default-days: 7
    groups:
      actions:
        patterns: ['*']

  - package-ecosystem: docker
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    open-pull-requests-limit: 2
    cooldown:
      default-days: 7
YAML

Points worth knowing:

  • The comment on the ignore rule matters. An ignore without a reason tends to outlive everyone who remembers why it was added. Put the reason and a review date next to it.
  • Ignore rules are broader than they look. GitHub marks ignore as an option that also shapes security updates, so a wide rule can hide a fix you need. Keep rules narrow: one package, one update type.
  • Per-level cooldowns only work where versions follow SemVer. npm supports semver-major-days and friends. Docker tags and GitHub Actions do not, so those two blocks use only default-days.
  • Setting open-pull-requests-limit: 0 pauses version updates for that ecosystem without deleting its block, which is handy during a release freeze.

On a prepaid or metered connection, these limits help beyond GitHub too: fewer, larger pull requests mean fewer branches to fetch and fewer npm install runs when you check an update locally.

Check it worked

Bash
cd ~/dependabot-demo/shop-web
check-jsonschema --builtin-schema vendor.dependabot .github/dependabot.yml | tee check.txt
grep -q 'ok -- validation done' check.txt
rm check.txt

It prints ok -- validation done. The schema also enforces ranges: cooldown days run from 1 to 90 (patch cooldown may be 0). See it catch an over-long cooldown in a scratch copy:

Bash
cd ~/dependabot-demo/shop-web
sed 's/semver-major-days: 30/semver-major-days: 120/' .github/dependabot.yml > /tmp/dependabot-bad.yml
if check-jsonschema --builtin-schema vendor.dependabot /tmp/dependabot-bad.yml > bad.txt 2>&1; then
  echo "expected a validation error"; false
fi
cat bad.txt
grep -q 'semver-major-days' bad.txt
rm bad.txt /tmp/dependabot-bad.yml

The output names semver-major-days and says that 120 is greater than the maximum of 90. Your real file is untouched.

Step 6 · Reach a private registry with a Dependabot secret

Suppose shop-web later depends on a private package published to GitHub Packages, such as @your-org/ui. Dependabot needs a token to read that registry, and it does not read your Actions secrets. It has its own store: Settings, then Secrets and variables, then Dependabot.

Create a fine-grained or classic personal access token that can read packages from that registry, then save it as a Dependabot secret. The command prompts for the value, so the token does not land in your shell history:

Bash
gh secret set NPM_READ_TOKEN --app dependabot --repo YOUR-ORG/shop-web

Then declare the registry at the top level of dependabot.yml and point the npm block at it. Replace the file one last time:

Bash
cd ~/dependabot-demo/shop-web
cat > .github/dependabot.yml <<'YAML'
version: 2

registries:
  github-npm:
    type: npm-registry
    url: https://npm.pkg.github.com
    token: ${{secrets.NPM_READ_TOKEN}}

updates:
  - package-ecosystem: npm
    directory: /
    registries:
      - github-npm
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    open-pull-requests-limit: 4
    cooldown:
      default-days: 5
      semver-major-days: 30
      semver-minor-days: 7
      semver-patch-days: 3
    ignore:
      # Express 6 needs a planned migration. Review this rule each quarter.
      - dependency-name: express
        update-types: ['version-update:semver-major']
    groups:
      npm-dev:
        dependency-type: development
        update-types: [minor, patch]
      npm-prod:
        dependency-type: production
        update-types: [minor, patch]
      npm-security:
        applies-to: security-updates
        patterns: ['*']

  - package-ecosystem: github-actions
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    open-pull-requests-limit: 2
    cooldown:
      default-days: 7
    groups:
      actions:
        patterns: ['*']

  - package-ecosystem: docker
    directory: /
    schedule:
      interval: weekly
      day: monday
      time: '06:00'
      timezone: Africa/Lagos
    open-pull-requests-limit: 2
    cooldown:
      default-days: 7
YAML

The file holds only a reference, ${{secrets.NPM_READ_TOKEN}}, never the token itself, so it is safe to commit. Secret names may contain letters, digits and underscores, cannot start with a digit or with GITHUB_, and are stored in upper case.

The separate store has a second effect that catches many teams out. When Dependabot opens a pull request, the CI workflows that run on it also get Dependabot secrets, not Actions secrets. If your CI needs NPM_READ_TOKEN to run npm install, add the secret in both places, or Dependabot's pull requests fail in CI while everyone else's pass.

Check it worked

Bash
cd ~/dependabot-demo/shop-web
check-jsonschema --builtin-schema vendor.dependabot .github/dependabot.yml | tee check.txt
grep -q 'ok -- validation done' check.txt
rm check.txt
grep -n 'secrets.NPM_READ_TOKEN' .github/dependabot.yml

Validation passes, and grep finds the reference on the token: line. On GitHub, Settings, Secrets and variables, Dependabot lists NPM_READ_TOKEN, and the Actions page beside it does not, unless you added it there too.

Step 7 · Commit, push and watch the first run

Bash
cd ~/dependabot-demo/shop-web
git add .github/dependabot.yml
git commit -m "Configure Dependabot version updates"
git log --oneline
Bash
git push

Dependabot notices the new file on the default branch and runs a first check soon after, without waiting for Monday. Version updates and security updates both open pull requests against the default branch; if you set target-branch for version updates, security updates still go to the default branch and ignore that block's options.

Check it worked

Within a few minutes the repository's Pull requests tab shows Dependabot pull requests: a grouped one for the action bumps (if newer releases exist), grouped npm ones and possibly a Docker base image bump. To see what each run did, open Insights, then Dependency graph, then the Dependabot tab, and choose Recent update jobs next to a manifest. A job that failed to reach the private registry says so in its log.

Review each pull request as you would a colleague's: read the release notes Dependabot links, let CI run, and merge when it passes. A bot proposing an update is not proof the update is safe.

Step 8 · Decide whether Dependabot is enough, or Renovate fits better

Renovate is the main alternative. Both open update pull requests; they differ in where they run and how much you can tune.

Text
Question                          Dependabot                          Renovate
--------------------------------  ----------------------------------  ----------------------------------
Where it runs                     Built into GitHub                   Mend-hosted app, or self-hosted
                                                                      from npm or a container image
Platforms                         GitHub                              GitHub, GitLab, Bitbucket, Azure
                                                                      DevOps, Gitea, Forgejo and others
Config file                       .github/dependabot.yml              renovate.json (or package.json)
Security updates                  Native, driven by Dependabot alerts Reads vulnerability data; set up
                                                                      in its config
Wait after a release              cooldown                            minimumReleaseAge
Auto-merge                        Not in the file; use a workflow     automerge option in the config
                                  that runs gh pr merge --auto
Overview of pending updates       Pull requests and job logs          Dependency Dashboard issue
Licence                           GitHub service                      Open source, AGPL-3.0

Pick one tool per repository: do not run Dependabot version updates and Renovate on the same repository at once, or both will open pull requests for the same bumps.

A rule of thumb: on GitHub, start with Dependabot. It needs no app to install and its security updates are tied directly to the alerts you already see. Move to Renovate when you need another Git platform, finer rules than groups and ignores give you, or one shared preset across many repositories.

Check it worked

Write one line at the top of .github/dependabot.yml as a comment, for example # Dependabot chosen: GitHub only, no auto-merge needed (reviewed 2026-11), then run the validator once more. It still prints ok -- validation done. Commit and push the change so it reaches GitHub:

Bash
git commit -am "Record why Dependabot was chosen"
git push

git log --oneline shows the new commit at the top, and the next person to open the file on GitHub knows why it exists.

Next steps

  • Compare the same setup in Renovate: /tutorials/keep-dependencies-up-to-date-with-renovate
  • Make sure every Dependabot pull request is tested before you merge it: /tutorials/run-node-tests-in-github-actions
  • Pin actions to commit hashes and tighten tokens, then let Dependabot keep the pins current: /tutorials/harden-github-actions-workflows
  • New to workflows: /tutorials/github-actions-first-workflow

Need this done for you?

Padding does this work for growing companies, from the first diagnosis to a system that keeps working.

Platform Engineering

Get new tutorials

New tutorials, about twice a month.