How to Set Up Dependabot Automationยถ

This guide shows you how to configure Dependabot for automated dependency management in the Qubinode KVM Host Setup Collection.

๐ŸŽฏ Goalยถ

Set up comprehensive Dependabot automation for:

  • Automated security updates

  • Regular dependency updates

  • GitHub Actions workflow updates

  • Container image updates for testing

  • Automated release triggers

๐Ÿ“‹ Prerequisitesยถ

  • Repository admin access

  • Understanding of GitHub repository settings

  • Familiarity with GitHub Actions workflows

  • Basic knowledge of dependency management

๐Ÿš€ Step 1: Enable Dependabot Featuresยถ

Repository Settingsยถ

Navigate to Settings > General > Features and enable:

  • โœ… Issues - Required for Dependabot to create issue reports

  • โœ… Pull Requests - Essential for Dependabot PRs

  • โœ… Actions - Required for automated workflow triggers

Organization Security Settingsยถ

Navigate to Organization Settings > Code security and analysis and enable:

  • โœ… Dependency graph - Required for Dependabot to analyze dependencies

  • โœ… Dependabot alerts - Security vulnerability notifications

  • โœ… Dependabot security updates - Automatic security fix PRs

  • โœ… Dependabot version updates - Regular dependency updates

๐Ÿ”ง Step 2: Configure Branch Protectionยถ

Navigate to Settings > Branches > Branch protection rules for the main branch:

Required Settingsยถ

  • โœ… Require pull request reviews before merging

  • โœ… Require status checks to pass before merging

  • โœ… Require branches to be up to date before merging

  • โœ… Include administrators (recommended)

Required Status Checksยถ

  • RHEL Compatibility Matrix Testing / validate-local-testing

  • RHEL Compatibility Matrix Testing / container-compatibility-validation

  • Ansible Lint / ansible-lint

  • Security Scan / security-scan

๐Ÿ“ Step 3: Create Dependabot Configurationยถ

Create .github/dependabot.yml:

version: 2
updates:
  # GitHub Actions dependencies
  - package-ecosystem: "github-actions"
    directory: "/"
    schedule:
      interval: "weekly"
      day: "monday"
      time: "09:00"
      timezone: "UTC"
    open-pull-requests-limit: 10
    reviewers:
      - "qubinode/maintainers"
    assignees:
      - "qubinode/maintainers"
    commit-message:
      prefix: "ci"
      include: "scope"
    labels:
      - "dependencies"
      - "github-actions"
      - "security"
    allow:
      - dependency-type: "direct"
        update-type: "version-update:semver-patch"

  # Docker dependencies for Molecule testing
  - package-ecosystem: "docker"
    directory: "/molecule"
    schedule:
      interval: "weekly"
      day: "tuesday"
      time: "09:00"
      timezone: "UTC"
    open-pull-requests-limit: 8
    commit-message:
      prefix: "ci"
      include: "scope"
    labels:
      - "dependencies"
      - "docker"
      - "testing"
      - "container-compatibility"

  # Python dependencies
  - package-ecosystem: "pip"
    directory: "/"
    schedule:
      interval: "daily"
      time: "09:00"
      timezone: "UTC"
    open-pull-requests-limit: 10
    commit-message:
      prefix: "deps"
      include: "scope"
    labels:
      - "dependencies"
      - "python"
      - "molecule"
    allow:
      - dependency-type: "direct"
        update-type: "security"

  # Ansible Galaxy dependencies
  - package-ecosystem: "gitsubmodule"
    directory: "/"
    schedule:
      interval: "weekly"
      day: "thursday"
      time: "09:00"
      timezone: "UTC"
    commit-message:
      prefix: "deps"
      include: "scope"
    labels:
      - "dependencies"
      - "ansible-galaxy"

๐Ÿค– Step 4: Set Up Auto-Merge Workflowยถ

Create .github/workflows/dependabot-auto-merge.yml:

name: Dependabot Auto-merge
on:
  pull_request:
    types: [opened, synchronize]

permissions:
  contents: write
  pull-requests: write
  checks: read

jobs:
  auto-merge:
    if: github.actor == 'dependabot[bot]'
    runs-on: ubuntu-latest
    steps:
      - name: Check if PR is ready for auto-merge
        id: check-pr
        run: |
          # Only auto-merge patch updates and security fixes
          if [[ "${{ github.event.pull_request.title }}" =~ ^(ci|deps)\(.*\):.*patch.*$ ]] || \
             [[ "${{ github.event.pull_request.title }}" =~ .*security.* ]]; then
            echo "auto_merge=true" >> $GITHUB_OUTPUT
          else
            echo "auto_merge=false" >> $GITHUB_OUTPUT
          fi

      - name: Enable auto-merge for safe updates
        if: steps.check-pr.outputs.auto_merge == 'true'
        run: |
          gh pr merge --auto --squash "$PR_URL"
        env:
          PR_URL: ${{ github.event.pull_request.html_url }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      - name: Add review request for major updates
        if: steps.check-pr.outputs.auto_merge == 'false'
        run: |
          gh pr edit "$PR_URL" --add-reviewer "qubinode/maintainers"
        env:
          PR_URL: ${{ github.event.pull_request.html_url }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

๐Ÿ”’ Step 5: Configure Security Settingsยถ

Enable Security Featuresยถ

Navigate to Settings > Code security and analysis:

  • โœ… Secret scanning - Detects accidentally committed secrets

  • โœ… Code scanning - Static analysis for vulnerabilities

  • โœ… Private vulnerability reporting - Responsible disclosure

Configure Vulnerability Alertsยถ

  • Set severity threshold to โ€œMediumโ€ or higher

  • Enable email notifications for maintainers

  • Configure Slack/Teams integration if desired

๐Ÿ‘ฅ Step 6: Set Up Team Permissionsยถ

Create Maintainers Teamยถ

  1. Navigate to Organization > Teams

  2. Create @qubinode/maintainers team

  3. Add appropriate maintainers

  4. Grant โ€œWriteโ€ access to repository

Configure Review Assignmentsยถ

In repository settings:

  • Set maintainers team as default reviewers

  • Configure auto-assignment for Dependabot PRs

  • Set up CODEOWNERS file if needed

โœ… Step 7: Test Dependabot Setupยถ

Manual Triggerยถ

# Trigger Dependabot manually (GitHub CLI)
gh api repos/:owner/:repo/dependabot/updates \
  --method POST \
  --field package_ecosystem=github-actions

Verify Configurationยถ

  1. Check Insights > Dependency graph

  2. Review Security > Dependabot alerts

  3. Monitor Actions tab for Dependabot workflows

๐Ÿ“Š Step 8: Monitor and Maintainยถ

Weekly Maintenance Tasksยถ

  • Review and merge Dependabot PRs

  • Check for failed status checks

  • Update auto-merge rules if needed

  • Review security alerts

Monthly Reviewยถ

  • Analyze Dependabot insights

  • Review update frequency and limits

  • Adjust configuration based on PR volume

  • Update team assignments if needed

Quarterly Assessmentยถ

  • Review overall dependency health

  • Update Dependabot configuration

  • Assess auto-merge effectiveness

  • Plan major dependency upgrades

๐Ÿšจ Troubleshootingยถ

Common Issuesยถ

Problem: Dependabot PRs not being created Solution:

  • Verify dependency files exist (requirements.txt, package.json)

  • Check Dependabot permissions in organization settings

  • Review branch protection rules for conflicts

Problem: Auto-merge not working Solution:

  • Verify all status checks are passing

  • Check that required reviews are satisfied

  • Ensure auto-merge is enabled in branch protection

Problem: Too many PRs being created Solution:

  • Reduce open-pull-requests-limit in dependabot.yml

  • Change update frequency from daily to weekly

  • Restrict allowed update types

Debug Commandsยถ

# Check Dependabot status
gh api repos/:owner/:repo/dependabot/updates

# List open Dependabot PRs
gh pr list --author "dependabot[bot]"

# Check workflow runs
gh run list --workflow="dependabot-auto-merge.yml"

๐ŸŽฏ Success Metricsยถ

Key Performance Indicatorsยถ

  • Security Response Time: < 24 hours for critical vulnerabilities

  • Update Frequency: Weekly for non-security updates

  • Auto-merge Rate: > 80% for patch updates

  • Manual Review Rate: < 20% requiring manual intervention

Monitoring Dashboardยถ

Track these metrics:

  • Number of Dependabot PRs per week

  • Time to merge security updates

  • Failed status checks on Dependabot PRs

  • Manual intervention frequency