Skip to content

Commit b7432d5

Browse files
authored
Merge pull request #364 from ergebnis/feature/merge
Enhancement: Restore auto-merge of dependabot pull requests
2 parents b665ccd + 8be757e commit b7432d5

File tree

5 files changed

+95
-98
lines changed

5 files changed

+95
-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
@@ -60,10 +60,6 @@ labels:
6060
color: "0e8a16"
6161
description: ""
6262

63-
- name: "merge"
64-
color: "6f42c1"
65-
description: ""
66-
6763
- name: "question"
6864
color: "cc317c"
6965
description: ""

.github/workflows/integrate.yaml

-94
Original file line numberDiff line numberDiff line change
@@ -333,97 +333,3 @@ jobs:
333333

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

.github/workflows/merge.yaml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
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+
- name: "Request review from @ergebnis-bot"
28+
uses: "actions/[email protected]"
29+
with:
30+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
31+
script: |
32+
const pullRequest = context.payload.workflow_run.pull_requests[0]
33+
const repository = context.repo
34+
35+
const reviewers = [
36+
"ergebnis-bot",
37+
]
38+
39+
await github.pulls.requestReviewers({
40+
owner: repository.owner,
41+
repo: repository.repo,
42+
pull_number: pullRequest.number,
43+
reviewers: reviewers,
44+
})
45+
46+
- name: "Assign @ergebnis-bot"
47+
uses: "actions/[email protected]"
48+
with:
49+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
50+
script: |
51+
const pullRequest = context.payload.workflow_run.pull_requests[0]
52+
const repository = context.repo
53+
54+
const assignees = [
55+
"ergebnis-bot",
56+
]
57+
58+
await github.issues.addAssignees({
59+
owner: repository.owner,
60+
repo: repository.repo,
61+
assignees: assignees,
62+
issue_number: pullRequest.number
63+
})
64+
65+
- name: "Approve pull request"
66+
uses: "actions/[email protected]"
67+
with:
68+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
69+
script: |
70+
const pullRequest = context.payload.workflow_run.pull_requests[0]
71+
const repository = context.repo
72+
73+
await github.pulls.createReview({
74+
event: "APPROVE",
75+
owner: repository.owner,
76+
repo: repository.repo,
77+
pull_number: pullRequest.number,
78+
})
79+
80+
- name: "Merge pull request"
81+
uses: "actions/[email protected]"
82+
with:
83+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
84+
script: |
85+
const pullRequest = context.payload.workflow_run.pull_requests[0]
86+
const repository = context.repo
87+
88+
await github.pulls.merge({
89+
merge_method: "merge",
90+
owner: repository.owner,
91+
pull_number: pullRequest.number,
92+
repo: repository.repo,
93+
})

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# json-printer
22

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

0 commit comments

Comments
 (0)