11name : Dependabot Auto-Merge
22
3- on : pull_request_target
3+ on :
4+ pull_request_target :
5+ types :
6+ - opened
7+ - synchronize
8+ - reopened
49
510permissions :
611 pull-requests : write
@@ -10,56 +15,34 @@ jobs:
1015 auto-merge :
1116 runs-on : ubuntu-latest
1217 if : github.event.pull_request.user.login == 'dependabot[bot]'
13-
18+
1419 steps :
1520 - name : Dependabot metadata
1621 id : metadata
1722 uses : dependabot/fetch-metadata@v2
1823 with :
1924 github-token : " ${{ secrets.GITHUB_TOKEN }}"
20-
21- # Auto-merge only for patch updates AND if CI passes
22- - name : Auto-merge patch updates (if CI passes)
23- if : |
24- steps.metadata.outputs.update-type == 'version-update:semver-patch'
25- run : |
26- PR="${{ github.event.pull_request.number }}"
2725
28- # Wait for CI checks to complete
29- gh pr checks "$PR" --watch --interval 10 --timeout 5m || true
30-
31- # Consider CI green only if every check concluded successfully
32- FAILED=$(gh pr checks "$PR" --json name,conclusion \
33- --jq '[.[] | select(.conclusion != "SUCCESS" and .conclusion != "NEUTRAL" and .conclusion != "SKIPPED")] | length')
34-
35- if [ "$FAILED" -eq 0 ]; then
36- echo "✅ CI passed! Auto-merging patch update..."
37- gh pr merge --auto --squash "$PR"
38- else
39- echo "❌ CI failed or incomplete. Skipping auto-merge for safety."
40- fi
41- env :
42- GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
43- GH_REPO : ${{ github.repository }}
44-
45- # Approve patch updates (only if we're auto-merging)
46- - name : Approve patch updates
47- if : |
48- steps.metadata.outputs.update-type == 'version-update:semver-patch'
26+ - name : Enable auto-merge for patch updates
27+ if : steps.metadata.outputs.update-type == 'version-update:semver-patch'
4928 run : |
50- gh pr review --approve "${{ github.event.pull_request.number }}" -b "Auto-approved by dependabot workflow"
29+ gh pr merge "${{ github.event.pull_request.number }}" \
30+ --auto \
31+ --squash
5132 env :
5233 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5334 GH_REPO : ${{ github.repository }}
54-
55- # For major/minor updates: add a label and comment to review manually
56- - name : Flag major/minor updates for manual review
35+
36+ - name : Flag minor and major updates for manual review
5737 if : |
5838 steps.metadata.outputs.update-type == 'version-update:semver-major' ||
5939 steps.metadata.outputs.update-type == 'version-update:semver-minor'
6040 run : |
61- gh pr comment "${{ github.event.pull_request.number }}" --body "⚠️ This is a **${{ steps.metadata.outputs.update-type }}** update. Please review manually before merging."
62- gh pr edit "${{ github.event.pull_request.number }}" --add-label "dependencies,manual-review-required"
41+ gh pr comment "${{ github.event.pull_request.number }}" \
42+ --body "⚠️ This is a **${{ steps.metadata.outputs.update-type }}** update. Please review manually before merging."
43+
44+ gh pr edit "${{ github.event.pull_request.number }}" \
45+ --add-label "dependencies,manual-review-required"
6346 env :
6447 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
6548 GH_REPO : ${{ github.repository }}
0 commit comments