-
-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (51 loc) · 1.92 KB
/
Copy pathauto-merge.yml
File metadata and controls
60 lines (51 loc) · 1.92 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
name: Auto-merge Dependabot PRs
on:
pull_request_target:
types:
- opened
- synchronize
- reopened
permissions:
contents: write
pull-requests: write
jobs:
auto-merge:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Get PR info
id: pr
uses: actions/github-script@v9
with:
script: |
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
// Auto-merge patch and minor updates
const title = pr.data.title.toLowerCase();
const isMinorOrPatch = title.includes('patch') ||
title.includes('minor') ||
title.match(/bump .+ from [\d]+\.[\d]+\.[\d]+ to [\d]+\.[\d]+\.[\d]+$/);
console.log('PR Title:', title);
console.log('Should merge:', isMinorOrPatch);
return { shouldMerge: isMinorOrPatch };
- name: Auto-approve Dependabot PR
if: fromJSON(steps.pr.outputs.result).shouldMerge
run: |
gh pr review ${{ github.event.pull_request.number }} --approve --body "Auto-approving dependency update"
gh pr merge ${{ github.event.pull_request.number }} --squash --auto
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment on failure
if: failure()
uses: actions/github-script@v9
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '🤖 Auto-merge failed. Please check the CI status and merge manually if appropriate.'
});