-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (61 loc) · 2.73 KB
/
Copy pathdependabot-auto-merge.yml
File metadata and controls
75 lines (61 loc) · 2.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Dependabot Auto-Merge
on:
pull_request:
types: [opened, synchronize, reopened]
permissions:
contents: write
pull-requests: write
jobs:
dependabot:
name: 🤖 Auto-merge Dependabot PRs
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: 📋 Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v2
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
- name: 🔍 Check update type
id: check-update
run: |
echo "Update type: ${{ steps.metadata.outputs.update-type }}"
echo "Dependency names: ${{ steps.metadata.outputs.dependency-names }}"
# Auto-approve security updates
if [[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-patch" ]] || \
[[ "${{ steps.metadata.outputs.update-type }}" == "version-update:semver-minor" ]] || \
[[ "${{ github.event.pull_request.labels[0].name }}" == "security" ]]; then
echo "auto_merge=true" >> $GITHUB_OUTPUT
else
echo "auto_merge=false" >> $GITHUB_OUTPUT
fi
- name: ✅ Auto-approve PR
if: steps.check-update.outputs.auto_merge == 'true'
run: gh pr review --approve "${{ github.event.pull_request.number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 🚀 Enable auto-merge
if: steps.check-update.outputs.auto_merge == 'true'
run: gh pr merge --auto --squash "${{ github.event.pull_request.number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: 💬 Comment on PR
if: steps.check-update.outputs.auto_merge == 'true'
run: |
gh pr comment "${{ github.event.pull_request.number }}" --body \
"🤖 **Auto-merge enabled** for this Dependabot PR.
✅ Update type: \`${{ steps.metadata.outputs.update-type }}\`
📦 Dependencies: ${{ steps.metadata.outputs.dependency-names }}
This will merge automatically once CI checks pass."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: ⚠️ Manual review required
if: steps.check-update.outputs.auto_merge == 'false'
run: |
gh pr comment "${{ github.event.pull_request.number }}" --body \
"⚠️ **Manual review required** for this major version update.
📦 Dependencies: ${{ steps.metadata.outputs.dependency-names }}
🔼 Update type: \`${{ steps.metadata.outputs.update-type }}\`
Please review breaking changes before merging."
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}