Skip to content

Commit c0ea014

Browse files
committed
restore dependabot auto merging using the workflow_run event
1 parent 2a2f779 commit c0ea014

File tree

2 files changed

+93
-94
lines changed

2 files changed

+93
-94
lines changed

.github/workflows/dependabot.yaml

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# https://docs.github.com/en/actions
2+
3+
name: "Dependabot Merge"
4+
5+
on:
6+
workflow_run:
7+
workflows: ["Integrate"]
8+
types:
9+
- "completed"
10+
11+
jobs:
12+
merge:
13+
name: "Merge"
14+
15+
runs-on: "ubuntu-latest"
16+
17+
if: >
18+
github.event.workflow_run.event == 'pull_request' &&
19+
github.event.workflow_run.conclusion == 'success' &&
20+
github.actor == 'dependabot[bot]' && (
21+
(startsWith(event.workflow_run.head_commit.message, 'composer(deps-dev)')) ||
22+
(startsWith(event.workflow_run.head_commit.message, 'github-actions(deps)'))
23+
)
24+
25+
steps:
26+
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+
})

.github/workflows/integrate.yaml

-94
Original file line numberDiff line numberDiff line change
@@ -169,100 +169,6 @@ jobs:
169169
- name: "Run maglnet/composer-require-checker"
170170
run: ".phive/composer-require-checker check --config-file=$(pwd)/composer-require-checker.json"
171171

172-
merge:
173-
name: "Merge"
174-
175-
runs-on: "ubuntu-latest"
176-
177-
needs:
178-
- "code-coverage"
179-
- "coding-standards"
180-
- "dependency-analysis"
181-
- "mutation-tests"
182-
- "static-code-analysis"
183-
- "tests"
184-
185-
if: >
186-
github.event_name == 'pull_request' &&
187-
github.event.pull_request.draft == false && (
188-
github.event.action == 'opened' ||
189-
github.event.action == 'reopened' ||
190-
github.event.action == 'synchronize'
191-
) && (
192-
(github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'composer(deps-dev)')) ||
193-
(github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'github-actions(deps)')) ||
194-
(github.actor == 'localheinz' && contains(github.event.pull_request.labels.*.name, 'merge'))
195-
)
196-
197-
steps:
198-
- name: "Request review from @ergebnis-bot"
199-
uses: "actions/[email protected]"
200-
with:
201-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
202-
script: |
203-
const pullRequest = context.payload.pull_request
204-
const repository = context.repo
205-
206-
const reviewers = [
207-
"ergebnis-bot",
208-
]
209-
210-
await github.pulls.requestReviewers({
211-
owner: repository.owner,
212-
pull_number: pullRequest.number,
213-
repo: repository.repo,
214-
reviewers: reviewers,
215-
})
216-
217-
- name: "Assign @ergebnis-bot"
218-
uses: "actions/[email protected]"
219-
with:
220-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
221-
script: |
222-
const pullRequest = context.payload.pull_request
223-
const repository = context.repo
224-
225-
const assignees = [
226-
"ergebnis-bot",
227-
]
228-
229-
await github.issues.addAssignees({
230-
assignees: assignees,
231-
issue_number: pullRequest.number,
232-
owner: repository.owner,
233-
repo: repository.repo,
234-
})
235-
236-
- name: "Approve pull request"
237-
uses: "actions/[email protected]"
238-
with:
239-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
240-
script: |
241-
const pullRequest = context.payload.pull_request
242-
const repository = context.repo
243-
244-
await github.pulls.createReview({
245-
event: "APPROVE",
246-
owner: repository.owner,
247-
pull_number: pullRequest.number,
248-
repo: repository.repo,
249-
})
250-
251-
- name: "Merge pull request"
252-
uses: "actions/[email protected]"
253-
with:
254-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
255-
script: |
256-
const pullRequest = context.payload.pull_request
257-
const repository = context.repo
258-
259-
await github.pulls.merge({
260-
merge_method: "merge",
261-
owner: repository.owner,
262-
pull_number: pullRequest.number,
263-
repo: repository.repo,
264-
})
265-
266172
mutation-tests:
267173
name: "Mutation Tests"
268174

0 commit comments

Comments
 (0)