Is it possible to allow dependabot on GitHub to automatically "bump" software to new version?


Please help this learner out: I get frequent GitHub’s dependabot alerts for "bumping" software versions to a more current one. My issue is I have to go into each (in my case, Django) app to pull or merge files. It tedious and time consuming to deal with my limited number of apps. How do professionals manage the process?

Is there a way to allow GitHub just bump whatever needs to be bumped (assuming one doesn’t mind apps being broken)?


Yes. You can use Github actions to do this. See the following blog post: Setting up Dependabot with GitHub actions to approve and merge

The code, the way it is now written, will only automatically merge minor and patch version changes. It will not merge major version changes, which are potentially breaking changes. You could remove that check, but it is not normally recommended.

You also need to change the following settings on your repo:

  • Settings -> Actions -> General -> check "Allow Github Actions to create and approve pull requests.
  • Settings -> General -> Pull Requests -> check "Allow auto-merge".

The contents of the Github workflow file, "dependabot-approve-and-auto-merge.yml", is:

name: Dependabot Pull Request Approve and Merge
on: pull_request_target
  pull-requests: write
  contents: write
    runs-on: ubuntu-latest
    # Checking the actor will prevent your Action run failing on non-Dependabot
    # PRs but also ensures that it only does work for Dependabot PRs.
    if: ${{ == 'dependabot[bot]' }}
      # This first step will fail if there's no metadata and so the approval
      # will not occur.
      - name: Dependabot metadata
        id: dependabot-metadata
        uses: dependabot/[email protected]
          github-token: "${{ secrets.GITHUB_TOKEN }}"
      # Here the PR gets approved.
      - name: Approve a PR
        run: gh pr review --approve "$PR_URL"
          PR_URL: ${{ github.event.pull_request.html_url }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
      # Finally, this sets the PR to allow auto-merging for patch and minor
      # updates if all checks pass
      - name: Enable auto-merge for Dependabot PRs
        if: ${{ steps.dependabot-metadata.outputs.update-type != 'version-update:semver-major' }}
        run: gh pr merge --auto --squash "$PR_URL"
          PR_URL: ${{ github.event.pull_request.html_url }}
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Answered By – John Pankowicz

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published