-
Notifications
You must be signed in to change notification settings - Fork 5.6k
55 lines (49 loc) · 1.43 KB
/
workflow-finished.yml
File metadata and controls
55 lines (49 loc) · 1.43 KB
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
name: Workflow Finished
run-name: Workflow Finished ${{ github.event.workflow_run.display_title }} (${{ github.event.workflow_run.conclusion }})
on:
workflow_run:
workflows:
- CI
types:
- completed
permissions:
contents: read
pull-requests: read
actions: write
jobs:
show-context:
name: Show Github Context
runs-on: ubuntu-latest
steps:
- name: event
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: |
echo "$GITHUB_CONTEXT"
restart-failed-jobs:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.run_attempt < 5 }}
needs:
- show-context
steps:
- name: Restart failed jobs
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: |
gh run rerun ${{ github.event.workflow_run.id }} --failed
# Branch protection rules require this to run with exit code 0.
set-pipeline-exit-status:
name: Set the ${{ github.event.workflow.name }} Pipeline Exit Status
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.run_attempt >= 5 }}
runs-on: ubuntu-latest
needs:
- show-context
steps:
- shell: bash
run:
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
exit 1;
else
exit 0;
fi