File tree 4 files changed +119
-0
lines changed 4 files changed +119
-0
lines changed Original file line number Diff line number Diff line change 8
8
- ' **'
9
9
- ' !.github/workflows/test-*'
10
10
- ' !buildkite/run/**'
11
+ - ' !check-dependent-jobs/**'
11
12
- ' !git/setup/**'
12
13
- ' !google/auth/**'
13
14
- ' !updatecli/run/**'
Original file line number Diff line number Diff line change
1
+ name : test-check-dependent-jobs
2
+
3
+ on :
4
+ pull_request :
5
+ branches :
6
+ - main
7
+ paths :
8
+ - ' .github/workflows/test-check-dependent-jobs.yml'
9
+ - ' check-dependent-jobs/**'
10
+ push :
11
+ branches :
12
+ - main
13
+ paths :
14
+ - ' .github/workflows/test-check-dependent-jobs.yml'
15
+ - ' check-dependent-jobs/**'
16
+
17
+ permissions :
18
+ contents : read
19
+
20
+ jobs :
21
+ test :
22
+ runs-on : ubuntu-latest
23
+ steps :
24
+ - uses : actions/checkout@v4
25
+ - uses : ./check-dependent-jobs
26
+ id : check
27
+ with :
28
+ jobs : ' { "job-a": { "result": "success" }, "job-b": { "result": "success" } }'
29
+ - name : assert outputs.is-success==true
30
+ run : test "${{ steps.check.outputs.is-success }}" = "true"
31
+ - uses : ./check-dependent-jobs
32
+ id : check-2
33
+ with :
34
+ jobs : ' { "job-a": { "result": "success" }, "job-b": { "result": "failure" } }'
35
+ - name : assert outputs.is-success==false
36
+ run : test "${{ steps.check-2.outputs.is-success }}" = "false"
37
+ - uses : ./check-dependent-jobs
38
+ id : check-3
39
+ with :
40
+ jobs : ' { "job-a": { "result": "failure" }, "job-b": { "result": "failure" } }'
41
+ - name : assert outputs.is-success==false
42
+ run : test "${{ steps.check-3.outputs.is-success }}" = "false"
Original file line number Diff line number Diff line change
1
+ # <!-- name--> check-dependent-jobs<!-- /name-->
2
+
3
+ <!-- description-->
4
+ Evaluates the combined the status results of the provided needs context.
5
+ <!-- /description-->
6
+
7
+ ## Inputs
8
+ <!-- inputs-->
9
+ | Name | Description | Required | Default |
10
+ | --------| ------------------------------| ----------| ---------|
11
+ | ` jobs ` | needs context as JSON string | ` true ` | ` ` |
12
+ <!-- /inputs-->
13
+
14
+ ## Outputs
15
+
16
+ <!-- outputs-->
17
+ | Name | Description |
18
+ | --------------| -----------------------------------------------------------------|
19
+ | ` is-success ` | The evaluated result of all provided jobs in the needs context. |
20
+ | ` status ` | One of success or failure. |
21
+ <!-- /outputs-->
22
+
23
+ ## Usage
24
+
25
+ <!-- usage action="elastic/oblt-actions/check-dependent-jobs" version="env:VERSION"-->
26
+ ``` yaml
27
+ jobs :
28
+ job-a :
29
+ runs-on : ubuntu-latest
30
+ steps :
31
+ - run : exit 1;
32
+ job-b :
33
+ runs-on : ubuntu-latest
34
+ steps :
35
+ - run : exit 0;
36
+ job-c :
37
+ if : always()
38
+ runs-on : ubuntu-latest
39
+ needs :
40
+ - job-a
41
+ - job-b
42
+ steps :
43
+ - id : check
44
+ uses : elastic/oblt-actions/check-dependent-jobs@v1
45
+ with :
46
+ jobs : ${{ toJSON(needs) }}
47
+ - run : ${{ steps.check.outputs.is-success }} # should exit with 1 or 0.
48
+ ` ` `
49
+ <!--/usage-->
Original file line number Diff line number Diff line change
1
+ name : check-dependent-jobs
2
+ description : |
3
+ Evaluates the combined the status results of the provided needs context.
4
+ inputs :
5
+ jobs :
6
+ required : true
7
+ description : needs context as JSON string
8
+ outputs :
9
+ is-success :
10
+ description : The evaluated result of all provided jobs in the needs context.
11
+ value : ${{ steps.test.outputs.is-success }}
12
+ status :
13
+ description : One of success or failure.
14
+ value : ${{ steps.test.outputs.status }}
15
+ runs :
16
+ using : composite
17
+ steps :
18
+ - id : test
19
+ uses : actions/github-script@v7
20
+ with :
21
+ script : |
22
+ const jobs = JSON.parse(process.env.JOBS)
23
+ const isSuccess = Object.values(jobs).every(job => job.result === 'success')
24
+ core.setOutput('is-success', isSuccess)
25
+ core.setOutput('status', isSuccess ? 'success' : 'failure')
26
+ env :
27
+ JOBS : ${{ inputs.jobs }}
You can’t perform that action at this time.
0 commit comments