# Adapted from https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request name: Dependabot auto-merge on: pull_request concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true permissions: pull-requests: write contents: write jobs: dependabot: runs-on: ubuntu-latest timeout-minutes: 10 # Only act on PRs opened by Dependabot from branches in this repository. if: github.actor == 'dependabot[bot]' && github.repository == github.event.pull_request.head.repo.full_name steps: # Metadata drives the non-major gating used for approval and auto-merge. - id: meta uses: dependabot/fetch-metadata@ffa630c65fa7e0ecfa0625b5ceda64399aea1b36 # v3.0.0 with: github-token: "${{ secrets.GITHUB_TOKEN }}" - name: Approve a PR if: ${{ steps.meta.outputs.update-type != 'version-update:semver-major' }} run: gh pr review --approve "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Enable auto-merge for Dependabot PRs if: ${{ steps.meta.outputs.update-type != 'version-update:semver-major' }} run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}