Enhancing Dependabot Auto-Merging: A Smarter, More Secure Approach

A shield floating in front of some code snippets

Did you know that outdated dependencies account for up to 68% of vulnerabilities in JavaScript applications?

In the past, I shared a method that leveraged GitHub Dependabot, Semantic Release, and automated workflows to streamline dependency updates while ensuring new versions were published seamlessly.

While effective, the approach had a few flaws — particularly regarding branch protection and the necessity of personal access tokens (PATs) for auto-merging. Since then, two major improvements have reshaped how I handle these updates: GitHub Rulesets and a GitHub App-Based Workflow. Let’s dive into the evolution of this method and explore how these changes simplify and secure the process.

Recap: The Old Workflow & Its Drawbacks

My original workflow automated dependency updates via Dependabot PRs, auto-merging them, and triggering Semantic Release to publish new versions. However, several concerns arose:

Improvement: GitHub Rulesets for Smarter Branch Protection

GitHub introduced Rulesets, a modular way to configure branch protection. The flexibility of rulesets allows for a dedicated account to bypass review requirements only for Dependabot PRs, while still enforcing other checks like:

This granular approach made it possible to replace the PAT through a GitHub App secret and use an Action to generate a token on the fly to merge the PRs.

While more secure, this solution just traded PAT management for app secret management, providing no improvement in that matter.

The Solution: A Webhook-Triggered GitHub App

Instead of merely using an app for authentication, I implemented an app-driven auto-merging solution that operates via webhooks:

  1. The app triggers a webhook on PR changes and workflow runs.
  2. The webhook fetches metadata using GitHub’s GraphQL API.
  3. It evaluates the PR using Dependabot’s own fetch-metadata logic.
  4. If all checks pass, the webhook merges the PR automatically.

Why This Approach Works Best

Conclusion

By leveraging GitHub Rulesets and a Webhook-Triggered GitHub App, auto-merging Dependabot PRs is now safer, more scalable, and easier to deploy. These enhancements remove security risks and maintenance efforts and ensure continuous updates without exposing sensitive credentials.

Want to try this approach for your repositories? Start by setting up a GitHub App and optimizing your branch protection rules — automation has never been this effortless.


Special Thanks & Acknowledgments

To Thomas Dupoiron from the GitHub team as well as Mugdha Deshmukh from the Atos Tooling team for the support as well as Lars Hermanns for all the code reviews during the implementation