Add retry logic to reviewer workflows (#56141)
This commit is contained in:
49
.github/actions/retry-command/action.yml
vendored
Normal file
49
.github/actions/retry-command/action.yml
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
name: 'Retry command'
|
||||
description: 'Retries any command with configurable attempts and delay'
|
||||
inputs:
|
||||
command:
|
||||
description: 'The command to retry'
|
||||
required: true
|
||||
max_attempts:
|
||||
description: 'Maximum number of retry attempts'
|
||||
required: false
|
||||
default: '8'
|
||||
delay:
|
||||
description: 'Delay between attempts in seconds'
|
||||
required: false
|
||||
default: '15'
|
||||
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Retry command
|
||||
shell: bash
|
||||
run: |
|
||||
# Generic retry function: configurable attempts and delay
|
||||
retry_command() {
|
||||
local max_attempts=${{ inputs.max_attempts }}
|
||||
local delay=${{ inputs.delay }}
|
||||
local attempt=1
|
||||
local command="${{ inputs.command }}"
|
||||
|
||||
while [ $attempt -le $max_attempts ]; do
|
||||
echo "Attempt $attempt/$max_attempts: Running command..."
|
||||
echo "Command: $command"
|
||||
if eval "$command"; then
|
||||
echo "Command succeeded on attempt $attempt"
|
||||
return 0
|
||||
else
|
||||
echo "Attempt $attempt failed"
|
||||
if [ $attempt -lt $max_attempts ]; then
|
||||
echo "Waiting $delay seconds before retry..."
|
||||
sleep $delay
|
||||
fi
|
||||
fi
|
||||
attempt=$((attempt + 1))
|
||||
done
|
||||
|
||||
echo "Command failed after $max_attempts attempts"
|
||||
return 1
|
||||
}
|
||||
|
||||
retry_command
|
||||
@@ -39,5 +39,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Add content systems as a reviewer
|
||||
run: |
|
||||
gh pr edit $PR --add-reviewer github/docs-content-systems --add-label reviewers-content-systems
|
||||
uses: ./.github/actions/retry-command
|
||||
with:
|
||||
command: gh pr edit $PR --add-reviewer github/docs-content-systems --add-label reviewers-content-systems
|
||||
|
||||
5
.github/workflows/reviewers-dependabot.yml
vendored
5
.github/workflows/reviewers-dependabot.yml
vendored
@@ -40,5 +40,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Add dependabot as a reviewer
|
||||
run: |
|
||||
gh pr edit $PR --add-reviewer github/dependabot-updates-reviewers --add-label reviewers-dependabot
|
||||
uses: ./.github/actions/retry-command
|
||||
with:
|
||||
command: gh pr edit $PR --add-reviewer github/dependabot-updates-reviewers --add-label reviewers-dependabot
|
||||
|
||||
@@ -51,5 +51,6 @@ jobs:
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Add docs engineering as a reviewer
|
||||
run: |
|
||||
gh pr edit $PR --add-reviewer github/docs-engineering --add-label reviewers-docs-engineering
|
||||
uses: ./.github/actions/retry-command
|
||||
with:
|
||||
command: gh pr edit $PR --add-reviewer github/docs-engineering --add-label reviewers-docs-engineering
|
||||
|
||||
5
.github/workflows/reviewers-legal.yml
vendored
5
.github/workflows/reviewers-legal.yml
vendored
@@ -54,8 +54,9 @@ jobs:
|
||||
|
||||
- name: Add legal as a reviewer
|
||||
if: steps.checkContentType.outputs.containsContentType == 'true'
|
||||
uses: ./.github/actions/retry-command
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.DOCS_BOT_PAT_BASE }}
|
||||
PR: ${{ github.event.pull_request.html_url }}
|
||||
run: |
|
||||
gh pr edit $PR --add-reviewer github/legal-product --add-label reviewers-legal
|
||||
with:
|
||||
command: gh pr edit $PR --add-reviewer github/legal-product --add-label reviewers-legal
|
||||
|
||||
Reference in New Issue
Block a user