GithubHelp home page GithubHelp logo

3rd-party-actions / retry Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nick-fields/retry

0.0 1.0 0.0 426 KB

Retries a GitHub Action step on failure or timeout

License: MIT License

JavaScript 17.07% Shell 2.49% TypeScript 80.44%

retry's Introduction

retry

Retries an Action step on failure or timeout. This is currently intended to replace the run step for moody commands.

Inputs

timeout_minutes

Required Minutes to wait before attempt times out. Must only specify either minutes or seconds

timeout_seconds

Required Seconds to wait before attempt times out. Must only specify either minutes or seconds

max_attempts

Required Number of attempts to make before failing the step

command

Required The command to run

retry_wait_seconds

Optional Number of seconds to wait before attempting the next retry. Defaults to 10

shell

Optional Shell to use to execute command. Defaults to powershell on Windows, bash otherwise. Supports bash, python, pwsh, sh, cmd, and powershell per docs

polling_interval_seconds

Optional Number of seconds to wait while polling for command result. Defaults to 1

retry_on

Optional Event to retry on. Currently supports [any (default), timeout, error].

warning_on_retry

Optional Whether to output a warning on retry, or just output to info. Defaults to true.

on_retry_command

Optional Command to run before a retry (such as a cleanup script). Any error thrown from retry command is caught and surfaced as a warning.

Outputs

total_attempts

The final number of attempts made

exit_code

The final exit code returned by the command

exit_error

The final error returned by the command

Examples

Shell

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  shell: pwsh
  command: dir

Timeout in minutes

uses: nick-invision/retry@v2
with:
  timeout_minutes: 10
  max_attempts: 3
  command: npm run some-typically-slow-script

Timeout in seconds

uses: nick-invision/retry@v2
with:
  timeout_seconds: 15
  max_attempts: 3
  command: npm run some-typically-fast-script

Only retry after timeout

uses: nick-invision/retry@v2
with:
  timeout_seconds: 15
  max_attempts: 3
  retry_on: timeout
  command: npm run some-typically-fast-script

Only retry after error

uses: nick-invision/retry@v2
with:
  timeout_seconds: 15
  max_attempts: 3
  retry_on: error
  command: npm run some-typically-fast-script

Retry but allow failure and do something with output

- uses: nick-invision/retry@v2
  id: retry
  # see https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-syntax-for-github-actions#jobsjob_idcontinue-on-error
  continue-on-error: true
  with:
    timeout_seconds: 15
    max_attempts: 3
    retry_on: error
    command: node -e 'process.exit(99);'
- name: Assert that action failed
  uses: nick-invision/assert-action@v1
  with:
    expected: failure
    actual: ${{ steps.retry.outcome }}
- name: Assert that action exited with expected exit code
  uses: nick-invision/assert-action@v1
  with:
    expected: 99
    actual: ${{ steps.retry.outputs.exit_code }}
- name: Assert that action made expected number of attempts
  uses: nick-invision/assert-action@v1
  with:
    expected: 3
    actual: ${{ steps.retry.outputs.total_attempts }}

Run script after failure but before retry

uses: nick-invision/retry@v2
with:
  timeout_seconds: 15
  max_attempts: 3
  command: npm run some-flaky-script-that-outputs-something
  on_retry_command: npm run cleanup-flaky-script-output

Run multi-line, multi-command script

name: Multi-line multi-command Test
uses: ./
with:
  timeout_minutes: 1
  max_attempts: 2
  command: |
    Get-ComputerInfo
    Get-Date

Run multi-line, single-command script

name: Multi-line single-command Test
uses: ./
with:
  timeout_minutes: 1
  max_attempts: 2
  shell: cmd
  command: >-
    echo "this is
 a test"

Requirements

NodeJS is required for this action to run. This runs without issue on all GitHub hosted runners but if you are running into issues with this on self hosted runners ensure NodeJS is installed.

retry's People

Contributors

dependabot[bot] avatar isaacrlevin avatar milahu avatar nick-invision avatar snyk-bot avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.