-
Notifications
You must be signed in to change notification settings - Fork 179
57 lines (52 loc) · 1.34 KB
/
test-failed-job.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
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
failed-job:
runs-on: ubuntu-latest
outputs:
output1: ${{ steps.step1.outputs.test }}
steps:
- name: failed-step-with-output
run: |
echo "This job will always fail"
echo "test=hello" >> "$GITHUB_OUTPUT"
exit 1
dependent-job:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() }}
steps:
- name: dependent-step
run: echo "This job is dependent on failed-job"
dependent-job-2:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() }}
steps:
- name: dependent-step
if: ${{ needs.failed-job.outputs.output1 == 'hello' }}
run: echo "This job is dependent on failed-job"
dependent-job-3:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() && needs.failed-job.outputs.output1 == 'hello' }}
steps:
- name: dependent-step
run: echo "This job is dependent on failed-job"
dependent-job-4:
runs-on: ubuntu-latest
needs: failed-job
if: ${{ always() }}
steps:
- name: dependent-step
if: ${{ needs.failed-job.result == 'failed' }}
run: |
echo "This job should fail"
exit 1
- name: this-not-fail
run: echo "do not fail"