1212 retries :
1313 description : " The number of retries to rerun the workflow"
1414 required : true
15+ github_repo :
16+ description : " The repository to rerun the workflow"
17+ required : true
18+ distinct_id :
19+ description : " The distinct id of the workflow to rerun"
20+ required : false
1521
1622jobs :
1723 gh-cli-rerun :
@@ -20,21 +26,25 @@ jobs:
2026 actions : write
2127 runs-on : ubuntu-latest
2228 env :
23- GH_TOKEN : " ${{ secrets.GITHUB_TOKEN }}"
29+ GH_TOKEN : " ${{ secrets.PERSONAL_TOKEN || github.token }}"
2430 steps :
25- - name : Host - Checkout action
31+ - name : Host - Checkout action ${{ inputs.distinct_id }}
2632 uses : actions/checkout@v4
2733
28- - name : gh cli rerun and summaries
34+ - name : gh cli rerun and summaries ${{ inputs.distinct_id }}
2935 if : inputs.attempts <= inputs.retries
3036 run : |
31- failures="$(gh run view ${{ inputs.run_id }} --log-failed | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")"
32- [[ -z "${failures}" ]] && failures="$(gh run view ${{ inputs.run_id }} | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")"
37+ github_repo="${{ inputs.github_repo || github.repository }}"
38+ failures="$(gh run view ${{ inputs.run_id }} --log-failed --repo "${github_repo}" | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")"
39+
40+ if [[ -z "${failures}" ]]; then
41+ failures="$(gh run view ${{ inputs.run_id }} --repo "${github_repo}" | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g")"
42+ fi
3343
3444 if [[ "${{ inputs.retries }}" -ge "2" ]]; then
35- gh run rerun "${{ inputs.run_id }}" --failed --debug
45+ gh run rerun "${{ inputs.run_id }}" --failed --debug --repo "${github_repo}"
3646 else
37- gh run rerun "${{ inputs.run_id }}" --failed
47+ gh run rerun "${{ inputs.run_id }}" --failed --repo "${github_repo}"
3848 fi
3949
4050 printf '%b\n' "# gh cli workflow reruns" >> $GITHUB_STEP_SUMMARY
0 commit comments