File tree Expand file tree Collapse file tree 5 files changed +61
-8
lines changed
Expand file tree Collapse file tree 5 files changed +61
-8
lines changed Original file line number Diff line number Diff line change 1+ name : ' Retry command'
2+ description : ' Retries any command with configurable attempts and delay'
3+ inputs :
4+ command :
5+ description : ' The command to retry'
6+ required : true
7+ max_attempts :
8+ description : ' Maximum number of retry attempts'
9+ required : false
10+ default : ' 8'
11+ delay :
12+ description : ' Delay between attempts in seconds'
13+ required : false
14+ default : ' 15'
15+
16+ runs :
17+ using : ' composite'
18+ steps :
19+ - name : Retry command
20+ shell : bash
21+ run : |
22+ # Generic retry function: configurable attempts and delay
23+ retry_command() {
24+ local max_attempts=${{ inputs.max_attempts }}
25+ local delay=${{ inputs.delay }}
26+ local attempt=1
27+ local command="${{ inputs.command }}"
28+
29+ while [ $attempt -le $max_attempts ]; do
30+ echo "Attempt $attempt/$max_attempts: Running command..."
31+ echo "Command: $command"
32+ if eval "$command"; then
33+ echo "Command succeeded on attempt $attempt"
34+ return 0
35+ else
36+ echo "Attempt $attempt failed"
37+ if [ $attempt -lt $max_attempts ]; then
38+ echo "Waiting $delay seconds before retry..."
39+ sleep $delay
40+ fi
41+ fi
42+ attempt=$((attempt + 1))
43+ done
44+
45+ echo "Command failed after $max_attempts attempts"
46+ return 1
47+ }
48+
49+ retry_command
Original file line number Diff line number Diff line change 3939 uses : actions/checkout@v4
4040
4141 - name : Add content systems as a reviewer
42- run : |
43- gh pr edit $PR --add-reviewer github/docs-content-systems --add-label reviewers-content-systems
42+ uses : ./.github/actions/retry-command
43+ with :
44+ command : gh pr edit $PR --add-reviewer github/docs-content-systems --add-label reviewers-content-systems
Original file line number Diff line number Diff line change 4040 uses : actions/checkout@v4
4141
4242 - name : Add dependabot as a reviewer
43- run : |
44- gh pr edit $PR --add-reviewer github/dependabot-updates-reviewers --add-label reviewers-dependabot
43+ uses : ./.github/actions/retry-command
44+ with :
45+ command : gh pr edit $PR --add-reviewer github/dependabot-updates-reviewers --add-label reviewers-dependabot
Original file line number Diff line number Diff line change 5151 uses : actions/checkout@v4
5252
5353 - name : Add docs engineering as a reviewer
54- run : |
55- gh pr edit $PR --add-reviewer github/docs-engineering --add-label reviewers-docs-engineering
54+ uses : ./.github/actions/retry-command
55+ with :
56+ command : gh pr edit $PR --add-reviewer github/docs-engineering --add-label reviewers-docs-engineering
Original file line number Diff line number Diff line change 5454
5555 - name : Add legal as a reviewer
5656 if : steps.checkContentType.outputs.containsContentType == 'true'
57+ uses : ./.github/actions/retry-command
5758 env :
5859 GH_TOKEN : ${{ secrets.DOCS_BOT_PAT_BASE }}
5960 PR : ${{ github.event.pull_request.html_url }}
60- run : |
61- gh pr edit $PR --add-reviewer github/legal-product --add-label reviewers-legal
61+ with :
62+ command : gh pr edit $PR --add-reviewer github/legal-product --add-label reviewers-legal
You can’t perform that action at this time.
0 commit comments