-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
705 lines (625 loc) · 28.2 KB
/
manage-prs.yml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
name: Manage PRs
env:
SUBMISSION_PARSER_VERSION: 1.1.1 # See: https://github.com/arduino/library-manager-submission-parser/releases
MAINTAINERS: |
# GitHub user names to request reviews from in cases where PRs can't be managed automatically.
- per1234
CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PREFIX: check-submissions-failed-
ERROR_MESSAGE_PREFIX: ":x: **ERROR:** "
on:
# pull_request_target trigger is used instead of pull_request so the token will have the write permissions needed to
# comment and merge.
# Note that this means the version of the workflow from the PR base ref will be used as opposed to the head ref, as is
# the case with pull_request triggered workflows.
# See: https://docs.github.com/actions/reference/events-that-trigger-workflows#pull_request_target
pull_request_target:
types:
- opened
- ready_for_review
- synchronize
issue_comment:
types:
- created
- edited
concurrency:
group: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
cancel-in-progress: >-
${{
(
github.event_name == 'pull_request_target' &&
github.event.pull_request.draft == false
) ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != '' &&
github.event.issue.state == 'open' &&
contains(github.event.comment.body, 'ArduinoBot')
)
}}
jobs:
diff:
if: >
(
github.event_name == 'pull_request_target' &&
github.event.pull_request.draft == false
) ||
(
github.event_name == 'issue_comment' &&
github.event.issue.pull_request != '' &&
github.event.issue.state == 'open' &&
contains(github.event.comment.body, 'ArduinoBot')
)
runs-on: ubuntu-latest
outputs:
artifact: ${{ steps.configuration.outputs.artifact }}
path: ${{ steps.configuration.outputs.path }}
filename: ${{ steps.configuration.outputs.filename }}
head: ${{ steps.head.outputs.head }}
env:
# See: https://docs.github.com/rest/reference/pulls#custom-media-types-for-pull-requests
DIFF_IDENTIFIER: diff
JSON_IDENTIFIER: raw+json
steps:
- name: Set configuration outputs
id: configuration
run: |
echo "::set-output name=artifact::diff"
echo "::set-output name=path::${{ runner.temp }}"
echo "::set-output name=filename::${{ env.DIFF_IDENTIFIER }}"
- name: Comment on comment trigger to provide feedback
if: github.event_name == 'issue_comment'
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# NOTE: "Unexpected input(s) ..." warnings for the arbitrary octokit/request-action inputs are normal and
# expected.
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.issue.number }}
body: |
|
Hello! I'm checking your submission again.
- name: Get PR data
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Two API requests are necessary, one for the PR diff and another for the metadata.
# It's necessary to reference both pull_request.number and issue.number because only one of the two are
# defined depending on whether the workflow is triggered by PR or comment event.
parallel \
' \
curl \
--fail \
--output "${{ steps.configuration.outputs.path }}/{}" \
--header "Authorization: token $GITHUB_TOKEN" \
--header "Accept: application/vnd.github.v3.{}" \
https://api.github.com/repos/${{ github.repository_owner }}/${{ github.event.repository.name }}/pulls/${{ github.event.pull_request.number }}${{ github.event.issue.number }}
' \
::: \
${{ env.DIFF_IDENTIFIER }} \
${{ env.JSON_IDENTIFIER }}
- name: Get head SHA of diff
id: head
run: echo "::set-output name=head::$(jq -c .head.sha "${{ steps.configuration.outputs.path }}/${{ env.JSON_IDENTIFIER }}")"
- name: Upload diff file to workflow artifact
uses: actions/upload-artifact@v4
with:
path: ${{ steps.configuration.outputs.path }}/${{ steps.configuration.outputs.filename }}
name: ${{ steps.configuration.outputs.artifact }}
parse:
needs:
- diff
runs-on: ubuntu-latest
outputs:
type: ${{ steps.parse-request.outputs.type }}
error: ${{ steps.parse-request.outputs.error }}
arduinoLintLibraryManagerSetting: ${{ steps.parse-request.outputs.arduinoLintLibraryManagerSetting }}
submissions: ${{ steps.parse-request.outputs.submissions }}
index-entry: ${{ steps.parse-request.outputs.index-entry }}
indexer-logs-urls: ${{ steps.parse-request.outputs.indexer-logs-urls }}
steps:
- name: Checkout local repository
uses: actions/checkout@v4
- name: Download submission parser
id: download-parser
uses: carlosperate/download-file-action@v2
with:
file-url: https://github.com/arduino/library-registry-submission-parser/releases/download/${{ env.SUBMISSION_PARSER_VERSION }}/parser
location: ${{ runner.temp }}
- name: Download diff
uses: actions/download-artifact@v4
with:
path: ${{ needs.diff.outputs.path }}
name: ${{ needs.diff.outputs.artifact }}
- name: Remove no longer needed artifact
uses: geekyeggo/delete-artifact@v5
with:
name: ${{ needs.diff.outputs.artifact }}
- name: Parse request
id: parse-request
run: |
chmod u+x "${{ steps.download-parser.outputs.file-path }}"
REQUEST="$( \
"${{ steps.download-parser.outputs.file-path }}" \
--diffpath="${{ needs.diff.outputs.path }}/${{ needs.diff.outputs.filename }}" \
--repopath="${{ github.workspace }}" \
--listname="repositories.txt" \
)"
# Due to limitations of the GitHub Actions workflow system, dedicated outputs must be created for use in
# certain workflow fields.
echo "::set-output name=type::$(echo "$REQUEST" | jq -r -c '.type')"
echo "::set-output name=error::$(echo "$REQUEST" | jq -r -c '.error')"
echo "::set-output name=arduinoLintLibraryManagerSetting::$(echo "$REQUEST" | jq -r -c '.arduinoLintLibraryManagerSetting')"
echo "::set-output name=submissions::$(echo "$REQUEST" | jq -c '.submissions')"
echo "::set-output name=index-entry::$(echo "$REQUEST" | jq -r -c '.indexEntry')"
echo "::set-output name=indexer-logs-urls::$(echo "$REQUEST" | jq -r -c '.indexerLogsURLs')"
label:
needs:
- parse
runs-on: ubuntu-latest
steps:
- name: Label PR
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: PUT /repos/{owner}/{repo}/issues/{issue_number}/labels
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
labels: |
- "topic: ${{ needs.parse.outputs.type }}"
parse-fail:
needs:
- parse
if: needs.parse.outputs.error != ''
runs-on: ubuntu-latest
steps:
- name: Comment on error detected while parsing PR
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Hi @${{ github.actor }}
A problem was found with your pull request:
${{ env.ERROR_MESSAGE_PREFIX }}${{ needs.parse.outputs.error }}
Please resolve this error. The checks will automatically run again once that is done.
More information:
https://github.com/${{ github.repository }}/blob/main/README.md#if-the-problem-is-with-the-pull-request
check-submissions:
name: Check ${{ matrix.submission.submissionURL }}
needs:
- parse
if: >
needs.parse.outputs.type == 'submission' ||
needs.parse.outputs.type == 'modification'
runs-on: ubuntu-latest
strategy:
fail-fast: false
# A matrix job will run for each of the submission URLs
matrix:
submission: ${{ fromJson(needs.parse.outputs.submissions) }}
steps:
- name: Set environment variables
run: |
echo "JSON_REPORT_PATH=${{ runner.temp }}/report.json" >> "$GITHUB_ENV"
echo "TEXT_REPORT_PATH=${{ runner.temp }}/report.txt" >> "$GITHUB_ENV"
echo "ARDUINO_LINT_INSTALLATION_PATH=${{ runner.temp }}/arduino-lint" >> "$GITHUB_ENV"
echo "PASS=true" >> "$GITHUB_ENV" # This variable stores the checks result
echo "FAIL_FLAG_PATH=${{ runner.temp }}/.check-submissions-failed" >> "$GITHUB_ENV"
# Submission PRs can be handled without maintainer involvement
- name: Remove prior review requests
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: DELETE /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
reviewers: ${{ env.MAINTAINERS }}
- name: Comment on error detected while parsing submission
if: matrix.submission.error != ''
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
A problem was found with your submission ${{ matrix.submission.submissionURL }}
${{ env.ERROR_MESSAGE_PREFIX }}${{ matrix.submission.error }}
- name: Set checks result to fail if error detected by submission parser
if: matrix.submission.error != ''
run: echo "PASS=false" >> "$GITHUB_ENV"
- name: Install Arduino Lint
if: env.PASS == 'true'
run: |
mkdir --parents "${{ env.ARDUINO_LINT_INSTALLATION_PATH }}"
curl \
-fsSL \
https://raw.githubusercontent.com/arduino/arduino-lint/main/etc/install.sh \
| \
BINDIR="${{ env.ARDUINO_LINT_INSTALLATION_PATH }}" \
sh
# actions/checkout can't be used because it only supports GitHub repos, while libraries may use other Git hosts
- name: Clone submission
if: env.PASS == 'true'
run: |
git clone \
--branch ${{ matrix.submission.tag }} \
--depth 1 ${{ matrix.submission.normalizedURL }} \
"${{ matrix.submission.repositoryName }}"
- name: Lint submission
id: arduino-lint
if: env.PASS == 'true'
continue-on-error: true # Error on linter rule violations is expected
run: |
export ARDUINO_LINT_OFFICIAL="${{ matrix.submission.official }}"
"${{ env.ARDUINO_LINT_INSTALLATION_PATH }}/arduino-lint" \
--compliance=permissive \
--format=text \
--library-manager=${{ needs.parse.outputs.arduinoLintLibraryManagerSetting }} \
--project-type=library \
--recursive=false \
--report-file="${{ env.JSON_REPORT_PATH }}" \
"${{ matrix.submission.repositoryName }}" > \
"${{ env.TEXT_REPORT_PATH }}"
- name: Read Arduino Lint reports
id: read-lint-report
if: env.PASS == 'true'
run: |
echo "::set-output name=json-report::$(jq -c . "${{ env.JSON_REPORT_PATH }}")"
# In order to use the text format report as a step output, it's necessary to do some character replacements.
TEXT_REPORT=$(cat "${{ env.TEXT_REPORT_PATH }}")
TEXT_REPORT="${TEXT_REPORT//'%'/'%25'}"
TEXT_REPORT="${TEXT_REPORT//$'\n'/'%0A'}"
TEXT_REPORT="${TEXT_REPORT//$'\r'/'%0D'}"
echo "::set-output name=text-report::$TEXT_REPORT"
- name: Comment on Arduino Lint warning
if: >
env.PASS == 'true'
&& fromJson(steps.read-lint-report.outputs.json-report).summary.warningCount > 0
&& fromJson(steps.read-lint-report.outputs.json-report).summary.errorCount == 0
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
[Arduino Lint](https://github.com/arduino/arduino-lint) has suggestions for possible improvements to ${{ matrix.submission.submissionURL }}:
```
${{ steps.read-lint-report.outputs.text-report }}
```
- name: Comment on Arduino Lint error
if: >
env.PASS == 'true'
&& fromJson(steps.read-lint-report.outputs.json-report).summary.errorCount > 0
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
${{ env.ERROR_MESSAGE_PREFIX }}[Arduino Lint](https://github.com/arduino/arduino-lint) found errors with ${{ matrix.submission.submissionURL }}:
```
${{ steps.read-lint-report.outputs.text-report }}
```
- name: Set checks result to fail if error detected by Arduino Lint
if: >
env.PASS == 'true'
&& steps.arduino-lint.outcome == 'failure'
run: echo "PASS=false" >> "$GITHUB_ENV"
- name: Create failure flag file
if: env.PASS == 'false'
run: touch ${{ env.FAIL_FLAG_PATH }} # Arbitrary file to provide content for the flag artifact
# Each workflow artifact must have a unique name. The job matrix doesn't provide a guaranteed unique string to use
# for a name so it is necessary to generate one.
- name: Generate unique artifact suffix
if: env.PASS == 'false'
run: |
echo "CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_SUFFIX=$(cat /proc/sys/kernel/random/uuid)" >> "$GITHUB_ENV"
# The value of a job matrix output is set by whichever job happened to run last, not of use for this application.
# So it's necessary to use an alternative means of indicating that at least one submission failed the checks.
- name: Upload failure flag artifact
if: env.PASS == 'false'
uses: actions/upload-artifact@v4
with:
if-no-files-found: error
include-hidden-files: true
path: ${{ env.FAIL_FLAG_PATH }}
name: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PREFIX }}${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_SUFFIX }}
check-submissions-result:
needs: check-submissions
runs-on: ubuntu-latest
outputs:
pass: ${{ steps.failure-flag-exists.outcome == 'failure' }}
env:
CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH: ${{ github.workspace }}/artifacts
steps:
- name: Download submission check failure flag artifacts
uses: actions/download-artifact@v4
with:
path: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH }}
pattern: ${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PREFIX }}*
- name: Check for existence of submission check failure flag artifact
id: failure-flag-exists
continue-on-error: true
# actions/download-artifact does not create a folder per its `path` input if no artifacts match `pattern`.
run: |
test -d "${{ env.CHECK_SUBMISSIONS_FAIL_FLAG_ARTIFACT_PATH }}"
check-submissions-fail:
needs:
- check-submissions-result
if: needs.check-submissions-result.outputs.pass == 'false'
runs-on: ubuntu-latest
steps:
- name: Comment instructions to fix errors detected during submission checks
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Thanks for your interest in contributing to the Arduino Library Manager index @${{ github.actor }}
Please resolve the error(s) mentioned in the previous comment.
After resolving the issue, trigger this check again by doing one of the following:
- **Commit the required change to the branch you submitted this pull request from.**
- **Comment here, mentioning `@ArduinoBot` in the comment.**
:exclamation: **NOTE**: It is not necessary to open a new pull request. :exclamation:
More information:
https://github.com/${{ github.repository }}/blob/main/README.md#if-the-problem-is-with-the-pull-request
merge:
needs:
- diff
- parse
- check-submissions-result
# Only merge submissions that passed all checks
if: >
needs.parse.outputs.type == 'submission'
&& needs.check-submissions-result.outputs.pass == 'true'
runs-on: ubuntu-latest
outputs:
pass: ${{ steps.merge.outcome == 'success' }}
status: ${{ steps.merge.outputs.status }}
steps:
- name: Approve pull request
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
event: APPROVE
- name: Merge pull request
id: merge
continue-on-error: true # Error in some situations (e.g., merge conflict) is expected
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: PUT /repos/{owner}/{repo}/pulls/{pull_number}/merge
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
sha: ${{ needs.diff.outputs.head }}
merge_method: squash
- name: Checkout index source branch
if: steps.merge.outcome == 'success'
uses: actions/checkout@v4
with:
ref: production
- name: Add index source file entry for submissions
if: steps.merge.outcome == 'success'
run: |
INDEX_SOURCE_FILE_PATH="${{ github.workspace }}/registry.txt"
git config --global user.email "bot@arduino.cc"
git config --global user.name "ArduinoBot"
echo "${{ needs.parse.outputs.index-entry }}" >> "$INDEX_SOURCE_FILE_PATH"
git add --update "$INDEX_SOURCE_FILE_PATH"
echo \
-e \
"Add submission # ${{ github.event.pull_request.number }}${{ github.event.issue.number }}\n\n${{ github.event.repository.html_url }}/pull/${{ github.event.pull_request.number }}${{ github.event.issue.number }}" \
| \
git commit \
--file -
git push
- name: Comment that submission was accepted
if: steps.merge.outcome == 'success'
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Your submission has now been accepted! Thanks for your contribution to the Arduino Library Manager index.
The library(s) will be available for installation via Library Manager within a day's time.
You can check the logs from the Library Manager indexer for your library(s) here:
${{ needs.parse.outputs.indexer-logs-urls }}
merge-fail:
needs:
- merge
# Only run if the PR could not be merged
if: needs.merge.outputs.pass == 'false'
runs-on: ubuntu-latest
steps:
- name: Comment on merge fail due to out of sync PR head branch causing downgraded token
if: needs.merge.outputs.status == '403'
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
${{ env.ERROR_MESSAGE_PREFIX }}Your submission meets all requirements. However, the pull request could not be merged.
Please follow this guide to sync your fork:
https://docs.github.com/github/collaborating-with-pull-requests/working-with-forks/syncing-a-fork
Once that is done, it will be merged automatically.
- name: Comment on merge conflict
if: needs.merge.outputs.status == '405'
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
${{ env.ERROR_MESSAGE_PREFIX }}Your submission meets all requirements. However, the pull request could not be merged.
Please follow this guide to resolve a merge conflict:
https://docs.github.com/github/collaborating-with-issues-and-pull-requests/resolving-a-merge-conflict-on-github
Once that is done, it will be merged automatically.
- name: Comment on diff head/PR head mismatch
if: needs.merge.outputs.status == '409'
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
It looks like there may have been an update to the pull request. If so, I'll check it again now.
- name: Fail on unidentified merge failure
if: >
needs.merge.outputs.status != '403' &&
needs.merge.outputs.status != '405' &&
needs.merge.outputs.status != '409'
run: exit 1 # Trigger the `unexpected-fail` job
not-submission:
needs:
- parse
# These request types can't be automatically approved.
if: >
needs.parse.outputs.type != 'submission' &&
needs.parse.outputs.type != 'invalid'
runs-on: ubuntu-latest
steps:
- name: Comment on required review
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Hi @${{ github.actor }}.
Your pull request has been detected as something other than a Library Manager submission.
A maintainer will need to review it before it can be merged.
If you intended to submit a library, please check the instructions and update your pull request if necessary:
https://github.com/${{ github.repository }}/blob/main/README.md#instructions
unexpected-fail:
needs:
# Run after all other jobs
- parse-fail
- merge-fail
- check-submissions-fail
- label
- not-submission
# Run if any job failed. The workflow is configured so that jobs only fail when there is an unexpected error.
if: failure()
runs-on: ubuntu-latest
steps:
- name: Label PR to indicate need for maintenance
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: PUT /repos/{owner}/{repo}/issues/{issue_number}/labels
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
labels: |
- "status: maintenance required"
- name: Comment on unexpected failure
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/issues/{issue_number}/comments
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
issue_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
body: |
|
Hi @${{ github.actor }}.
There was an unexpected failure during automated processing of your pull request.
This error is unrelated to the content of your pull request.
A maintainer has been notified and will investigate as soon as possible.
- name: Slack notification of unexpected failure
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.TEAM_TOOLING_CHANNEL_SLACK_WEBHOOK }}
SLACK_MESSAGE: |
:warning::warning::warning::warning:
WARNING: ${{ github.repository }} ${{ github.workflow }} workflow run had an unexpected failure!!!
:warning::warning::warning::warning:
SLACK_COLOR: danger
MSG_MINIMAL: true
request-review:
needs:
- parse-fail
- merge-fail
- not-submission
- unexpected-fail
if: >
always() &&
(
needs.parse-fail.result != 'skipped' ||
needs.merge-fail.result != 'skipped' ||
needs.not-submission.result != 'skipped' ||
needs.unexpected-fail.result != 'skipped'
)
runs-on: ubuntu-latest
steps:
- name: Request pull request review from maintainer
if: contains(toJSON(env.MAINTAINERS), github.actor) != true # Don't attempt to request review from PR author.
uses: octokit/request-action@v2.x
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
route: POST /repos/{owner}/{repo}/pulls/{pull_number}/requested_reviewers
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.pull_request.number }}${{ github.event.issue.number }}
reviewers: ${{ env.MAINTAINERS }}