GitHub Action
retry action
Retries a Github Action step or command on failure.
Works with either shell commands or other actions to retry.
Github actions which use the Internet connection can fail when connection is lost :
Run actions/setup-node@v1
connect ETIMEDOUT 104.20.22.46:443
Waiting 15 seconds before trying again
connect ETIMEDOUT 104.20.22.46:443
Waiting 18 seconds before trying again
Error: connect ETIMEDOUT 104.20.22.46:443
It is a cause of failed jobs. For this case, the action wretry.action
can retry the action immediately after fail or with some delay. And if the connection will be restored, then the job will continue the normal run.
- Retries Github
JavaScript
actions. - Retries
GitHub Docker
actions utilizing aDockerfile
as the image source. - Retries private actions. The option
github_token
is used for private repositories. - The action can be an action repository that is not published on
Marketplace
. - Retries shell commands. Uses default shells to run commands.
- Can retry single action or single command ( multiline command ), but not both simultaneously.
- Retries
main
,pre
andpost
stages of external actions. - Always has
pre
andpost
stages. If external action haspre
or/andpost
stage, then action run it also. - Action handles conditions in
JavaScript
actions ( fieldspre-if
andpost-if
). Some conditions can be unsolvable and then action skips the stage. - Executes only the main script of Docker actions, excluding pre-entrypoint and post-entrypoint scripts.
- Resolves external action default inputs from next contexts :
github
,env
,job
,matrix
,inputs
. - Retries actions with defined number of attempts ( default is 2 ).
- Retries actions with defined delay between attempts ( default is 0 ).
The name of a Github action. Format is {owner}/{repo_name}@{ref}
.
Attention. Action requires defined action
or command
. If the fields action
and commands
are defined simultaneously, then action will throw error.
The command to run. The action runs the command in the default shell.
Attention. Action requires defined action
or command
. If the fields action
and commands
are defined simultaneously, then action will throw error.
An options map for Github action. It is a multiline string with pairs key : value
.
An example of declaration of option with single line value :
- uses: Wandalen/wretry.action@master
with:
action: owner/action-repo@version
with: |
option1: value
option2: value
An example of declaration of option with multiline string :
- uses: Wandalen/wretry.action@master
with:
action: owner/action-repo@version
with: |
option1: |
value1
value2
value3
option2: value
Setup working directory for the action. Works with only commands. Default is github.workspace
path.
Set number of attempts. Default is 2.
Set delay between attempts in ms. Default is 0.
Set time out in ms for entire step including all retries. By default actions sets no time out.
A token to access private actions. Does not required for public actions.
The action exposes single output named outputs
. It collects all the outputs from the action/command in JSON map.
To access the value from an external action outputs parse the wretry.action
output and select required key. To parse the outputs use builtin Github Actions function fromJSON
.
Let's look at an example:
jobs:
job1:
runs-on: ubuntu-latest
outputs:
# extract `outputs` from a step
out: ${{ steps.my-action.outputs.outputs }}
steps:
- id: my-action
uses: Wandalen/wretry.action@1.2.0
with:
attempt_limit: 3
action: user/action@version
with: |
foo: bar
job2:
runs-on: ubuntu-latest
needs: job1
steps:
- env:
# parse full map and store it to OUPUT1
OUTPUT1: ${{ fromJSON( needs.job1.outputs.out ) }}
# parse full map and extract field `foo`
OUTPUT2: ${{ fromJSON( needs.job1.outputs.out ).foo }}
run: echo "$OUTPUT1 $OUTPUT2"
To setup job output we access output outputs
of the step my-action
. In the job job2
we parse this output to JSON. The environment variable OUPUT1
represents full JSON and the variable OUPUT2
represents key foo
of the parsed JSON.
- uses: Wandalen/wretry.action@master
with:
action: action/setup-node@2.3.0
with: |
node-version: 14.x
architecture: x64
attempt_limit: 3
attempt_delay: 2000
- uses: Wandalen/wretry.action@master
with:
command: npm i
attempt_limit: 3
attempt_delay: 2000
To build compiled dependencies utility willbe
is required. To install utility run :
npm i -g 'willbe@latest'
willbe
is not required to use the action in your project as submodule.