1
0
mirror of synced 2025-12-25 02:17:36 -05:00

Add retry logic to reviewer workflows (#56141)

This commit is contained in:
Kevin Heis
2025-06-20 14:21:44 -07:00
committed by GitHub
parent 0560de36f1
commit 7596051ef1
5 changed files with 61 additions and 8 deletions

View 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

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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