Skip to content

Commit 5236b3b

Browse files
committed
Enhancement: Extract merge workflow
1 parent f368e79 commit 5236b3b

File tree

2 files changed

+49
-94
lines changed

2 files changed

+49
-94
lines changed

.github/workflows/integrate.yaml

Lines changed: 0 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -134,100 +134,6 @@ jobs:
134134
- name: "Run friendsofphp/php-cs-fixer"
135135
run: "tools/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --dry-run --verbose"
136136

137-
merge:
138-
name: "Merge"
139-
140-
runs-on: "ubuntu-latest"
141-
142-
needs:
143-
- "backward-compatibility"
144-
- "code-coverage"
145-
- "coding-standards"
146-
- "static-code-analysis"
147-
- "tests"
148-
149-
if: >
150-
github.event_name == 'pull_request' &&
151-
github.event.pull_request.draft == false && (
152-
github.event.action == 'opened' ||
153-
github.event.action == 'reopened' ||
154-
github.event.action == 'synchronize'
155-
) && (
156-
(github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'composer(deps-dev)')) ||
157-
(github.actor == 'dependabot[bot]' && startsWith(github.event.pull_request.title, 'github-actions(deps)')) ||
158-
(github.actor == 'localheinz' && contains(github.event.pull_request.labels.*.name, 'merge'))
159-
)
160-
161-
steps:
162-
- name: "Request review from @ergebnis-bot"
163-
uses: "actions/github-script@v2"
164-
with:
165-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
166-
script: |
167-
const pullRequest = context.payload.pull_request
168-
const repository = context.repo
169-
170-
const reviewers = [
171-
"ergebnis-bot",
172-
]
173-
174-
await github.pulls.createReviewRequest({
175-
owner: repository.owner,
176-
pull_number: pullRequest.number,
177-
repo: repository.repo,
178-
reviewers: reviewers,
179-
})
180-
181-
- name: "Assign @ergebnis-bot"
182-
uses: "actions/github-script@v2"
183-
with:
184-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
185-
script: |
186-
const pullRequest = context.payload.pull_request
187-
const repository = context.repo
188-
189-
const reviewers = [
190-
"ergebnis-bot",
191-
]
192-
193-
await github.issues.addAssignees({
194-
assignees: reviewers,
195-
issue_number: pullRequest.number,
196-
owner: repository.owner,
197-
repo: repository.repo,
198-
})
199-
200-
- name: "Approve pull request"
201-
uses: "actions/github-script@v2"
202-
if: "github.actor != 'ergebnis-bot'"
203-
with:
204-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
205-
script: |
206-
const pullRequest = context.payload.pull_request
207-
const repository = context.repo
208-
209-
await github.pulls.createReview({
210-
event: "APPROVE",
211-
owner: repository.owner,
212-
pull_number: pullRequest.number,
213-
repo: repository.repo,
214-
})
215-
216-
- name: "Merge pull request"
217-
uses: "actions/github-script@v2"
218-
with:
219-
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
220-
script: |
221-
const pullRequest = context.payload.pull_request
222-
const repository = context.repo
223-
224-
await github.pulls.merge({
225-
merge_method: "merge",
226-
owner: repository.owner,
227-
pull_number: pullRequest.number,
228-
repo: repository.repo,
229-
})
230-
231137
static-code-analysis:
232138
name: "Static Code Analysis"
233139

.github/workflows/merge.yaml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
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+
timeout-minutes: 5
19+
20+
if: >
21+
github.event.workflow_run.event == 'pull_request' &&
22+
github.event.workflow_run.conclusion == 'success' &&
23+
github.actor == 'dependabot[bot]' && (
24+
startsWith(github.event.workflow_run.head_commit.message, 'composer(deps-dev)') ||
25+
startsWith(github.event.workflow_run.head_commit.message, 'github-actions(deps)')
26+
)
27+
28+
steps:
29+
- name: "Request review from @ergebnis-bot"
30+
uses: "ergebnis/.github/actions/github/pull-request/request-review@1.9.2"
31+
with:
32+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
33+
reviewer: "ergebnis-bot"
34+
35+
- name: "Assign @ergebnis-bot"
36+
uses: "ergebnis/.github/actions/github/pull-request/add-assignee@1.9.2"
37+
with:
38+
assignee: "ergebnis-bot"
39+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
40+
41+
- name: "Approve pull request"
42+
uses: "ergebnis/.github/actions/github/pull-request/approve@1.9.2"
43+
with:
44+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"
45+
46+
- name: "Merge pull request"
47+
uses: "ergebnis/.github/actions/github/pull-request/merge@1.9.2"
48+
with:
49+
github-token: "${{ secrets.ERGEBNIS_BOT_TOKEN }}"

0 commit comments

Comments
 (0)