File tree 3 files changed +62
-9
lines changed
3 files changed +62
-9
lines changed Original file line number Diff line number Diff line change 4
4
pull_request :
5
5
6
6
jobs :
7
- build :
8
- name : test
7
+ test-default :
8
+ name : test success
9
9
runs-on : ubuntu-latest
10
10
steps :
11
+ - name : Checkout repository
12
+ uses : actions/checkout@v3
13
+ with :
14
+ fetch-depth : 0
15
+ - name : retry
16
+ uses : ./
17
+ with :
18
+ command : true
11
19
20
+ test-fail-command-1 :
21
+ name : test fail command 1
22
+ runs-on : ubuntu-latest
23
+ steps :
12
24
- name : Checkout repository
13
25
uses : actions/checkout@v3
14
26
with :
15
27
fetch-depth : 0
28
+ - name : retry
29
+ uses : ./
30
+ with :
31
+ command : false
32
+ retries : 2
33
+ pause : 1
34
+ fail_command : |
35
+ echo "This command has failed" \
36
+ && echo "Failed command concatenated"
37
+ continue-on-error : true
16
38
39
+ test-fail-command-2 :
40
+ name : test fail command 2
41
+ runs-on : ubuntu-latest
42
+ steps :
43
+ - name : Checkout repository
44
+ uses : actions/checkout@v3
45
+ with :
46
+ fetch-depth : 0
17
47
- name : retry
18
48
uses : ./
19
49
with :
20
- command : true
50
+ command : false
51
+ retries : 2
52
+ pause : 1
53
+ fail_command : |
54
+ sudo sysctl -w net.ipv4.ip_forward=1 \
55
+ && sudo systemctl restart docker
56
+ continue-on-error : true
Original file line number Diff line number Diff line change @@ -12,12 +12,13 @@ This action allows you to retry shell command for a few times in case they fail.
12
12
13
13
The following inputs can be used to alter the Docker tag name determination:
14
14
15
- | Input | Required | Default | Description |
16
- | -----------| ----------| ----------| -------------------------------------------|
17
- | ` retries ` | No | ` 10 ` | How many times to retry on failure. |
18
- | ` pause ` | No | ` 10 ` | How many seconds to wait between retries. |
19
- | ` command ` | Yes | `` | Shell command to execute |
20
- | ` workdir ` | No | `` | Switch to this working directory prior executing the shell command |
15
+ | Input | Required | Default | Description |
16
+ | ----------------| ----------| ----------| -------------------------------------------|
17
+ | ` retries ` | No | ` 10 ` | How many times to retry on failure. |
18
+ | ` pause ` | No | ` 10 ` | How many seconds to wait between retries. |
19
+ | ` command ` | Yes | `` | Shell command to execute. |
20
+ | ` workdir ` | No | `` | Switch to this working directory prior executing the shell command. |
21
+ | ` fail_command ` | No | `` | Shell command to execute on every failure of given ` command ` . |
21
22
22
23
23
24
## :arrow_backward : Outputs
48
49
pause : 10
49
50
command : |
50
51
docker build -t test .
52
+ # Builing docker sometimes fails on GH Action runner due to network issues.
53
+ # We ensure that forwarding is reenabled and the daemon is restarted
54
+ # Before retrying the docker build command
55
+ fail_command : |
56
+ sudo sysctl -w net.ipv4.ip_forward=1 \
57
+ && sudo systemctl restart docker \
51
58
` ` `
52
59
53
60
Original file line number Diff line number Diff line change @@ -19,6 +19,10 @@ inputs:
19
19
description : ' Shell command to execute'
20
20
required : true
21
21
default : ' true'
22
+ fail_command :
23
+ description : ' Shell command to execute on every failure of given command (The fail_command will always succeed via: || true)'
24
+ required : false
25
+ default : ' '
22
26
workdir :
23
27
description : ' Switch to this working directory prior executing shell command'
24
28
required : false
37
41
echo "[SUCC] ${n}/${RETRIES}";
38
42
return 0;
39
43
fi;
44
+ if [ -n "${FAIL_COMMAND}" ]; then
45
+ echo "Executing fail command:";
46
+ echo "${FAIL_COMMAND}";
47
+ eval "${FAIL_COMMAND}" || true;
48
+ fi;
40
49
sleep ${PAUSE};
41
50
echo "[FAIL] ${n}/${RETRIES}";
42
51
done;
51
60
PAUSE : ${{ inputs.pause }}
52
61
COMMAND : ${{ inputs.command }}
53
62
WORKDIR : ${{ inputs.workdir }}
63
+ FAIL_COMMAND : ${{ inputs.fail_command }}
You can’t perform that action at this time.
0 commit comments