diff --git a/.github/workflows/livecheck.yml b/.github/workflows/livecheck.yml index 7dfed63..e2d8a38 100644 --- a/.github/workflows/livecheck.yml +++ b/.github/workflows/livecheck.yml @@ -4,6 +4,12 @@ on: pull_request: schedule: - cron: 34 5 * * * + workflow_dispatch: + inputs: + retry: + description: 'Retry attempt' + required: true + type: number jobs: livecheck: runs-on: ubuntu-latest @@ -13,18 +19,17 @@ jobs: with: ruby-version: '3' bundler-cache: true - - run: | - MAX_ATTEMPTS=10 - for ((attempt = 1; ; attempt++)); do - echo "#### Attempt $attempt" - if bundle exec script/livecheck; then - exit + - env: + RETRY: ${{ inputs.retry }} + RETRIES: 10 + GITHUB_TOKEN: ${{ secrets.RETRY_TOKEN }} + run: | + if ! bundle exec script/livecheck; then + exit_code=$? + if (( $exit_code == 2 )) && (( ${RETRY:-0} < $RETRIES )); then + sleep 300 + gh workflow run livecheck --repo $GITHUB_REPOSITORY --ref $GITHUB_REF_NAME -f retry=$(( $RETRY + 1 )) else - exit_code=$? - if [ $exit_code -eq 2 ] && [ $attempt -lt $MAX_ATTEMPTS ]; then - sleep 300 - else - exit $exit_code - fi + exit $exit_code fi - done + fi