-
-
Notifications
You must be signed in to change notification settings - Fork 101
40 lines (35 loc) · 1.11 KB
/
retry.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
name: Retry Workflow
on:
workflow_run:
workflows: ["CI"]
types:
- completed
permissions:
contents: write
actions: write
jobs:
rerun:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- name: Check attempt count
id: check_attempts
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
run: |
attempt=$(gh run view ${{ github.event.workflow_run.id }} --json attempt -q ".attempt")
echo "Current attempt: $attempt"
if [ $attempt -lt 3 ]; then
echo "attempt_allowed=true" >> $GITHUB_OUTPUT
else
echo "attempt_allowed=false" >> $GITHUB_OUTPUT
fi
- name: rerun ${{ github.event.workflow_run.id }}
if: steps.check_attempts.outputs.attempt_allowed == 'true'
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
run: |
gh run watch ${{ github.event.workflow_run.id }} > /dev/null 2>&1
gh run rerun ${{ github.event.workflow_run.id }} --failed