Skip to content

Commit 2bb8595

Browse files
committed
Enhancement: Restore auto-merge of dependabot pull requests
1 parent 9b3746c commit 2bb8595

File tree

5 files changed

+96
-98
lines changed

5 files changed

+96
-98
lines changed

.github/CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ We are using [GitHub Actions](https://github.com/features/actions) as a continuo
55
For details, take a look at the following workflow configuration files:
66

77
- [`workflows/integrate.yaml`](workflows/integrate.yaml)
8+
- [`workflows/merge.yaml`](workflows/merge.yaml)
89
- [`workflows/prune.yaml`](workflows/prune.yaml)
910
- [`workflows/release.yaml`](workflows/release.yaml)
1011
- [`workflows/renew.yaml`](workflows/renew.yaml)

.github/settings.yml

-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,6 @@ labels:
5757
color: "0e8a16"
5858
description: ""
5959

60-
- name: "merge"
61-
color: "6f42c1"
62-
description: ""
63-
6460
- name: "question"
6561
color: "cc317c"
6662
description: ""

.github/workflows/integrate.yaml

-94
Original file line numberDiff line numberDiff line change
@@ -332,97 +332,3 @@ jobs:
332332

333333
- name: "Run mutation tests with pcov and infection/infection"
334334
run: "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=${{ env.MIN_COVERED_MSI }} --min-msi=${{ env.MIN_MSI }}"
335-
336-
merge:
337-
name: "Merge"
338-
339-
runs-on: "ubuntu-latest"
340-
341-
needs:
342-
- "code-coverage"
343-
- "coding-standards"
344-
- "dependency-analysis"
345-
- "mutation-tests"
346-
- "static-code-analysis"
347-
- "tests"
348-
349-
if: >
350-
github.event_name == 'pull_request' &&
351-
github.event.pull_request.draft == false && (
352-
github.event.action == 'opened' ||
353-
github.event.action == 'reopened' ||
354-
github.event.action == 'synchronize'
355-
) && (
356-
(github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'composer(deps-dev)')) ||
357-
(github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'github-actions(deps)')) ||
358-
(github.actor == 'localheinz' && contains(github.event.pull_request.labels.*.name, 'merge'))
359-
)
360-
361-
steps:
362-
- name: "Request review from @ergebnis-bot"
363-
uses: "actions/[email protected]"
364-
with:
365-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
366-
script: |
367-
const pullRequest = context.payload.pull_request
368-
const repository = context.repo
369-
370-
const reviewers = [
371-
"ergebnis-bot",
372-
]
373-
374-
await github.pulls.requestReviewers({
375-
owner: repository.owner,
376-
pull_number: pullRequest.number,
377-
repo: repository.repo,
378-
reviewers: reviewers,
379-
})
380-
381-
- name: "Assign @ergebnis-bot"
382-
uses: "actions/[email protected]"
383-
with:
384-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
385-
script: |
386-
const pullRequest = context.payload.pull_request
387-
const repository = context.repo
388-
389-
const assignees = [
390-
"ergebnis-bot",
391-
]
392-
393-
await github.issues.addAssignees({
394-
assignees: assignees,
395-
issue_number: pullRequest.number,
396-
owner: repository.owner,
397-
repo: repository.repo,
398-
})
399-
400-
- name: "Approve pull request"
401-
uses: "actions/[email protected]"
402-
with:
403-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
404-
script: |
405-
const pullRequest = context.payload.pull_request
406-
const repository = context.repo
407-
408-
await github.pulls.createReview({
409-
event: "APPROVE",
410-
owner: repository.owner,
411-
pull_number: pullRequest.number,
412-
repo: repository.repo,
413-
})
414-
415-
- name: "Merge pull request"
416-
uses: "actions/[email protected]"
417-
with:
418-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
419-
script: |
420-
const pullRequest = context.payload.pull_request
421-
const repository = context.repo
422-
423-
await github.pulls.merge({
424-
merge_method: "merge",
425-
owner: repository.owner,
426-
pull_number: pullRequest.number,
427-
repo: repository.repo,
428-
})

.github/workflows/merge.yaml

+94
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
# https://docs.github.com/en/actions
2+
3+
name: "Merge"
4+
5+
on: # yamllint disable-line rule:truthy
6+
workflow_run:
7+
types:
8+
- "completed"
9+
workflows:
10+
- "Integrate"
11+
12+
jobs:
13+
merge:
14+
name: "Merge"
15+
16+
runs-on: "ubuntu-latest"
17+
18+
if: >
19+
github.event.workflow_run.event == 'pull_request' &&
20+
github.event.workflow_run.conclusion == 'success' &&
21+
github.actor == 'dependabot[bot]' && (
22+
startsWith(github.event.workflow_run.head_commit.message, 'composer(deps-dev)') ||
23+
startsWith(github.event.workflow_run.head_commit.message, 'github-actions(deps)')
24+
)
25+
26+
steps:
27+
28+
- name: "Request review from @ergebnis-bot"
29+
uses: "actions/[email protected]"
30+
with:
31+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
32+
script: |
33+
const pullRequest = context.payload.workflow_run.pull_requests[0]
34+
const repository = context.repo
35+
36+
const reviewers = [
37+
"ergebnis-bot",
38+
]
39+
40+
await github.rest.pulls.requestReviewers({
41+
owner: repository.owner,
42+
repo: repository.repo,
43+
pull_number: pullRequest.number,
44+
reviewers: reviewers,
45+
})
46+
47+
- name: "Assign @ergebnis-bot"
48+
uses: "actions/[email protected]"
49+
with:
50+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
51+
script: |
52+
const pullRequest = context.payload.workflow_run.pull_requests[0]
53+
const repository = context.repo
54+
55+
const assignees = [
56+
"ergebnis-bot",
57+
]
58+
59+
await github.rest.issues.addAssignees({
60+
owner: repository.owner,
61+
repo: repository.repo,
62+
assignees: assignees,
63+
issue_number: pullRequest.number
64+
})
65+
66+
- name: "Approve pull request"
67+
uses: "actions/[email protected]"
68+
with:
69+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
70+
script: |
71+
const pullRequest = context.payload.workflow_run.pull_requests[0]
72+
const repository = context.repo
73+
74+
await github.rest.pulls.createReview({
75+
event: "APPROVE",
76+
owner: repository.owner,
77+
repo: repository.repo,
78+
pull_number: pullRequest.number,
79+
})
80+
81+
- name: "Merge pull request"
82+
uses: "actions/[email protected]"
83+
with:
84+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
85+
script: |
86+
const pullRequest = context.payload.workflow_run.pull_requests[0]
87+
const repository = context.repo
88+
89+
await github.rest.pulls.merge({
90+
merge_method: "merge",
91+
owner: repository.owner,
92+
pull_number: pullRequest.number,
93+
repo: repository.repo,
94+
})

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# phpstan-rules
22

33
[![Integrate](https://github.com/ergebnis/phpstan-rules/workflows/Integrate/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)
4+
[![Merge](https://github.com/ergebnis/phpstan-rules/workflows/Merge/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)
45
[![Prune](https://github.com/ergebnis/phpstan-rules/workflows/Prune/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)
56
[![Release](https://github.com/ergebnis/phpstan-rules/workflows/Release/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)
67
[![Renew](https://github.com/ergebnis/phpstan-rules/workflows/Renew/badge.svg)](https://github.com/ergebnis/phpstan-rules/actions)

0 commit comments

Comments
 (0)