Skip to content

Commit 0e85978

Browse files
authored
Add FAQ section with solution for required matrix jobs (#283)
1 parent ed436fa commit 0e85978

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,33 @@ stateDiagram-v2
404404
Skipped_No --> Dont_Skip: (Because changed files needs to be "tested")
405405
```
406406

407+
## Frequently Asked Questions
408+
409+
### Skip Check in Required Matrix Job
410+
411+
Discussed in https://github.com/fkirc/skip-duplicate-actions/issues/44.
412+
413+
If you have matrix jobs that are registered as required status checks and the matrix runs conditionally based on the skip check, you might run into the problem that the pull request remains in a unmergable state forever because the jobs are not executed at all and thus not reported as skipped (`Expected - Waiting for status to be reported`).
414+
415+
There are several approaches to circumvent this problem:
416+
417+
- Define the condition (`if`) in each step in the matrix job instead of a single condition on the job level: https://github.com/fkirc/skip-duplicate-actions/issues/44
418+
- If you want the check to be considered successful only if all jobs in the matrix were successful, you can add a subsequent job whose only task is to report the final status of the matrix. Then you can register this final job as a required status check:
419+
```yaml
420+
result:
421+
name: Result
422+
if: needs.pre_job.outputs.should_skip != 'true' && always()
423+
runs-on: ubuntu-latest
424+
needs:
425+
- pre_job
426+
- example-matrix-job
427+
steps:
428+
- name: Mark result as failed
429+
if: needs.example-matrix-job.result != 'success'
430+
run: exit 1
431+
```
432+
- Define an opposite workflow, as offically suggested by GitHub: [Handling skipped but required checks](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks)
433+
407434
## Maintainers
408435

409436
- [@paescuj](https://github.com/paescuj)

0 commit comments

Comments
 (0)