diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index fa52ad1..111ce76 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -1,4 +1,5 @@ name: Automerge Dependabot PRs + on: pull_request_target permissions: @@ -15,8 +16,19 @@ jobs: uses: dependabot/fetch-metadata@v2 with: github-token: "${{ secrets.GITHUB_TOKEN }}" + - name: Enable auto-merge for Dependabot PRs - run: gh pr merge --auto --squash "$PR_URL" + run: | + if gh pr merge --auto --squash "$PR_URL"; then + echo "PR merged successfully" + else + MERGEABLE=$(gh pr view "$PR_URL" --json mergeable --jq '.mergeable') + if [ "$MERGEABLE" = "CONFLICTING" ]; then + gh pr comment "$PR_URL" --body "@dependabot recreate" + else + echo "Merge failed for another reason" + fi + fi env: PR_URL: ${{github.event.pull_request.html_url}} GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}