-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
46 lines (41 loc) · 1.7 KB
/
reruns.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
name: Rerun Workflow Runs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TERM: xterm-256color
##########################################################################
concurrency:
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}"
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'apereo/cas' }}
on:
workflow_run:
workflows:
- Functional Tests
- Unit & Integration Tests
- Dependencies
- Code Analysis
- Publish Documentation
- Validation
- Build
types:
- completed
branches:
- master
##########################################################################
jobs:
rerun-failed-jobs:
runs-on: ubuntu-latest
continue-on-error: true
if: ${{ github.event.workflow_run.conclusion == 'failure' && github.event.workflow_run.status == 'completed' }}
steps:
- name: Rerunning ${{ github.event.workflow_run.name }}
run: |
echo "Workflow run ID: ${{ github.event.workflow_run.id }}"
echo "Workflow run Name: ${{ github.event.workflow_run.name }}"
echo "Workflow run attempt #: ${{ github.event.workflow_run.run_attempt }}"
CURRENT_ATTEMPTS=${{ github.event.workflow_run.run_attempt }}
if [ "$CURRENT_ATTEMPTS" -le 2 ]; then
echo "Rerunning failed workflow jobs for workflow ${{ github.event.workflow_run.name }}..."
gh api --method POST -H "Accept: application/vnd.github+json" /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }}/rerun-failed-jobs
else
echo "Max run attempts reached. Not rerunning."
fi