diff --git a/.github/workflows/dependabot-auto-merge.yml b/.github/workflows/dependabot-auto-merge.yml index f7fe387..0eda329 100644 --- a/.github/workflows/dependabot-auto-merge.yml +++ b/.github/workflows/dependabot-auto-merge.yml @@ -1,15 +1,25 @@ name: Dependabot Auto-Merge -on: pull_request +on: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] permissions: contents: write pull-requests: write +# Prevent multiple runs on the same PR +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number }} + cancel-in-progress: false + jobs: dependabot-auto-merge: runs-on: ubuntu-latest - if: github.actor == 'dependabot[bot]' + # Only run for Dependabot PRs that are not drafts + if: | + github.actor == 'dependabot[bot]' && + github.event.pull_request.draft == false steps: - name: Fetch Dependabot metadata @@ -34,11 +44,17 @@ jobs: PR_URL: ${{ github.event.pull_request.html_url }} GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Auto-merge patch and minor updates + - name: Enable auto-merge for patch updates + if: steps.metadata.outputs.update-type == 'version-update:semver-patch' + run: gh pr merge --auto --squash "$PR_URL" + env: + PR_URL: ${{ github.event.pull_request.html_url }} + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Enable auto-merge for minor dev dependency updates if: | - steps.metadata.outputs.update-type == 'version-update:semver-patch' || - (steps.metadata.outputs.update-type == 'version-update:semver-minor' && - steps.metadata.outputs.dependency-type == 'direct:development') + steps.metadata.outputs.update-type == 'version-update:semver-minor' && + steps.metadata.outputs.dependency-type == 'direct:development' run: gh pr merge --auto --squash "$PR_URL" env: PR_URL: ${{ github.event.pull_request.html_url }}