-
-
Notifications
You must be signed in to change notification settings - Fork 0
628 lines (612 loc) · 27 KB
/
test-action.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
name: Test GitHub action
on:
workflow_run:
workflows: [
"Markdown Link Check with errors",
"Markdown Link Check without errors",
]
types:
- completed
defaults:
run:
shell: pwsh
env:
# Need to checkout the same commit from the workflow run that triggered this workflow.
# By default the checkout step gets the latest from master but that's not what we want.
# Without checking out the workflow run head sha the errors that we get into are like:
# - Create a PR, that will run the workflows that trigger this one but then, instead of
# checking commit from the PR, we get the commit from master. This would mean we would
# run this workflow which builds the docker image and runs tests using the incorrect commit.
WORKFLOW_HEAD_SHA : ${{ github.event.workflow_run.head_sha }}
jobs:
trigger-info:
name: Trigger info
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- name: Trigger info
run: |
Write-Output "::notice::This worklfow was triggered by a 'workflow_run' from '${{ github.event.workflow_run.name }}'."
only-errors-true-files-output:
name: only-errors set to true - files output
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with only errors set to true
id: mlc-log-parser
uses: ./action-local
with:
repo: '${{ github.repository }}'
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
only-errors: 'true'
output: 'file-json, file-md'
json-filepath: './mlc-json-result-1.json'
markdown-filepath: './mlc-md-result-1.md'
- name: Verify json file output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-with-capture-errors-only.json
$file2 = Get-Content ${{ github.workspace }}/mlc-json-result-1.json
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output JSON file doesn't match expected JSON file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output JSON file matches expected JSON file."
}
- name: Verify md file output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-with-capture-errors-only.md
$file2 = Get-Content ${{ github.workspace }}/mlc-md-result-1.md
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output Markdown file doesn't match expected Markdown file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output Markdown file matches expected Markdown file."
}
- name: Verify json file output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.json
$file2 = Get-Content ${{ github.workspace }}/mlc-json-result-1.json
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output JSON file doesn't match expected JSON file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output JSON file matches expected JSON file."
}
- name: Verify md file output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.md
$file2 = Get-Content ${{ github.workspace }}/mlc-md-result-1.md
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output Markdown file doesn't match expected Markdown file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output Markdown file matches expected Markdown file."
}
only-errors-true-json-step-output:
name: only-errors set to true - json step output
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with only errors set to true
id: mlc-log-parser
uses: ./action-local
with:
repo: '${{ github.repository }}'
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
only-errors: 'true'
output: 'step-json'
- name: Dump outputs from previous step
run: |
Write-Output "${{ steps.mlc-log-parser.outputs.mlc-result }}"
- name: Verify json step output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-with-capture-errors-only.json -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = '${{ steps.mlc-log-parser.outputs.mlc-result }}'
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::JSON step output doesn't match expected JSON. See failed step for more information."
Exit 1
}
else
{
Write-Output "JSON step output matches expected JSON."
}
- name: Verify json step output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.json -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = '${{ steps.mlc-log-parser.outputs.mlc-result }}'
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::JSON step output doesn't match expected JSON. See failed step for more information."
Exit 1
}
else
{
Write-Output "JSON step output matches expected JSON."
}
only-errors-true-md-step-output:
name: only-errors set to true - md step output
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with markdown step output
id: mlc-log-parser
uses: ./action-local
with:
repo: '${{ github.repository }}'
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
only-errors: 'true'
output: 'step-md'
- name: Dump outputs from previous step
run: |
Write-Output "${{ steps.mlc-log-parser.outputs.mlc-result }}"
- name: Verify md step output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-with-capture-errors-only.md -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = "${{ steps.mlc-log-parser.outputs.mlc-result }}"
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Markdown step output doesn't match expected Markdown. See failed step for more information."
Exit 1
}
else
{
Write-Output "Markdown step output matches expected Markdown."
}
- name: Verify md step output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.md -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = "${{ steps.mlc-log-parser.outputs.mlc-result }}"
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Markdown step output doesn't match expected Markdown. See failed step for more information."
Exit 1
}
else
{
Write-Output "Markdown step output matches expected Markdown."
}
only-errors-false-files-output:
name: only-errors set to false - files output
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with only errors set to false
id: mlc-log-parser
uses: ./action-local
with:
repo: '${{ github.repository }}'
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
only-errors: 'false'
output: 'file-json, file-md'
json-filepath: './mlc-json-result-2.json'
markdown-filepath: './mlc-md-result-2.md'
- name: Verify json file output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-without-capture-errors-only.json
$file2 = Get-Content ${{ github.workspace }}/mlc-json-result-2.json
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output JSON file doesn't match expected JSON file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output JSON file matches expected JSON file."
}
- name: Verify md file output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-without-capture-errors-only.md
$file2 = Get-Content ${{ github.workspace }}/mlc-md-result-2.md
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output Markdown file doesn't match expected Markdown file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output Markdown file matches expected Markdown file."
}
- name: Verify json file output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.json
$file2 = Get-Content ${{ github.workspace }}/mlc-json-result-2.json
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output JSON file doesn't match expected JSON file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output JSON file matches expected JSON file."
}
- name: Verify md file output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
$file1 = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.md
$file2 = Get-Content ${{ github.workspace }}/mlc-md-result-2.md
$compareResult = Compare-Object -ReferenceObject $file1 -DifferenceObject $file2
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Output Markdown file doesn't match expected Markdown file. See failed step for more information."
Exit 1
}
else
{
Write-Output "Output Markdown file matches expected Markdown file."
}
only-errors-false-json-step-output:
name: only-errors set to false - json step output
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with only errors set to false
id: mlc-log-parser
uses: ./action-local
with:
repo: '${{ github.repository }}'
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
only-errors: 'false'
output: 'step-json'
- name: Dump outputs from previous step
run: |
Write-Output "${{ steps.mlc-log-parser.outputs.mlc-result }}"
- name: Verify json step output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-without-capture-errors-only.json -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = '${{ steps.mlc-log-parser.outputs.mlc-result }}'
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::JSON step output doesn't match expected JSON. See failed step for more information."
Exit 1
}
else
{
Write-Output "JSON step output matches expected JSON."
}
- name: Verify json step output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.json -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = '${{ steps.mlc-log-parser.outputs.mlc-result }}'
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::JSON step output doesn't match expected JSON. See failed step for more information."
Exit 1
}
else
{
Write-Output "JSON step output matches expected JSON."
}
only-errors-false-md-step-output:
name: only-errors set to false - md step output
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with markdown step output
id: mlc-log-parser
uses: ./action-local
with:
repo: '${{ github.repository }}'
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
only-errors: 'false'
output: 'step-md'
- name: Dump outputs from previous step
run: |
Write-Output "${{ steps.mlc-log-parser.outputs.mlc-result }}"
- name: Verify md step output for mlc with errors
if: github.event.workflow_run.name == 'Markdown Link Check with errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/with-errors/result-without-capture-errors-only.md -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = "${{ steps.mlc-log-parser.outputs.mlc-result }}"
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Markdown step output doesn't match expected Markdown. See failed step for more information."
Exit 1
}
else
{
Write-Output "Markdown step output matches expected Markdown."
}
- name: Verify md step output for mlc without errors
if: github.event.workflow_run.name == 'Markdown Link Check without errors'
run: |
# Split expected output and received output by newlines because the Compare-Object below will present diffs by line and without this
# everything would be only 1 line, not great for diff results.
$file = Get-Content ${{ github.workspace }}/.github/workflows/markdown-link-check-files/expected-file-outputs/without-errors/result.md -Raw
$file = $file.Split([System.Environment]::NewLine)
$stepOutput = "${{ steps.mlc-log-parser.outputs.mlc-result }}"
$stepOutput = $stepOutput.Split([System.Environment]::NewLine)
$compareResult = Compare-Object -ReferenceObject $file -DifferenceObject $stepOutput
Write-Output $compareResult
Write-Output ''
if($compareResult)
{
Write-Output "::error::Markdown step output doesn't match expected Markdown. See failed step for more information."
Exit 1
}
else
{
Write-Output "Markdown step output matches expected Markdown."
}
default-args:
name: default args
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with default action args
uses: ./action-local
id: mlc-log-parser
with:
run-id: '${{ github.event.workflow_run.id }}'
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
- name: Dump outputs from previous step
run: |
$result = '${{ steps.mlc-log-parser.outputs.mlc-result }}' | ConvertFrom-Json
Write-Output "Total files checked: $($result.TotalFilesChecked)"
Write-Output "Total links chedked: $($result.TotalLinksChecked)"
Write-Output "Has erros: $($result.HasErrors)"
$resultAsJsonIndented = ConvertTo-Json -Depth 4 $result
Write-Output $resultAsJsonIndented # outputs the markdown link check result as an indented JSON string
test-failure:
name: test failure
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- uses: actions/checkout@v4
with:
ref: ${{ env.WORKFLOW_HEAD_SHA }}
- name: Run markdown link check log parser with bad input
id: mlc-log-parser-bad-input
uses: ./action-local
continue-on-error: true
with:
repo: '${{ github.repository }}'
run-id: '1' # invalid run id
job-name: 'Run Markdown Link Check'
step-name: 'Markdown Link Check'
- name: The action should fail the step if it encounters an error
run: |
$errorOutcome = '${{ steps.mlc-log-parser-bad-input.outcome }}'
if($errorOutcome -eq 'success') {
Write-Output "::error title=Action check:Action should have failed the workflow because of invalid input but it didn't."
Exit 1
}
else {
Write-Output "::notice title=Action check::Action would have failed the workflow given invalid input. You should see an error message on the action's Annotations."
}
pr-status:
name: Set PR status
needs: [
only-errors-true-files-output,
only-errors-true-json-step-output,
only-errors-true-md-step-output,
only-errors-false-files-output,
only-errors-false-json-step-output,
only-errors-false-md-step-output,
default-args,
test-failure,
]
if: github.event.workflow_run.event == 'pull_request' && always()
permissions:
statuses: write
runs-on: ubuntu-latest
steps:
- name: Dump github context for debug purposes
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: $env:GITHUB_CONTEXT
- name: Create GitHub status on PR
run: |
$onlyErrorsTrueFilesOutputJobResult = '${{ needs.only-errors-true-files-output.result }}'
$onlyErrorsTrueJsonStepOutputJobResult = '${{ needs.only-errors-true-json-step-output.result }}'
$onlyErrorsTrueMdStepOutputJobResult = '${{ needs.only-errors-true-md-step-output.result }}'
$onlyErrorsFalseFilesOutputJobResult = '${{ needs.only-errors-false-files-output.result }}'
$onlyErrorsFalseJsonStepOutputJobResult = '${{ needs.only-errors-false-json-step-output.result }}'
$onlyErrorsFalseMdStepOutputJobResult = '${{ needs.only-errors-false-md-step-output.result }}'
$defaultArgsJobResult = '${{ needs.default-args.result }}'
$testFailureJobResult = '${{ needs.test-failure.result }}'
if ($onlyErrorsTrueFilesOutputJobResult -eq 'success' `
-and $onlyErrorsTrueJsonStepOutputJobResult -eq 'success' `
-and $onlyErrorsTrueMdStepOutputJobResult -eq 'success' `
-and $onlyErrorsFalseFilesOutputJobResult -eq 'success' `
-and $onlyErrorsFalseJsonStepOutputJobResult -eq 'success' `
-and $onlyErrorsFalseMdStepOutputJobResult -eq 'success' `
-and $defaultArgsJobResult -eq 'success' `
-and $testFailureJobResult -eq 'success')
{
$description = 'Successful'
$state = 'success'
}
else
{
$description = 'Error'
$state = 'error'
}
$uri = "https://api.github.com/repos/${{ github.repository }}/statuses/${{ github.event.workflow_run.head_sha }}"
$headers = @{
Accept = "application/vnd.github.v3+json"
Authorization = "Bearer ${{ secrets.GITHUB_TOKEN }}"
}
$body = @{
context = '${{ github.workflow }} / ${{ github.event.workflow_run.name }} (${{ github.event_name }})' # mimic format from github
description = $description
target_url = 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}'
state = $state
} | ConvertTo-Json -compress
Invoke-RestMethod -Method 'Post' -Uri $uri -Headers $headers -Body $body