File tree Expand file tree Collapse file tree 5 files changed +16
-3
lines changed Expand file tree Collapse file tree 5 files changed +16
-3
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ inputs:
1212 attempts :
1313 description : " Max attempts"
1414 required : true
15+ on-fail :
16+ description : " Execute bash command on fail"
17+ required : false
1518runs :
1619 using : " docker"
1720 image : " Dockerfile"
Original file line number Diff line number Diff line change 1919 uses : ./
2020 with :
2121 url : www.google.com
22- attempts : 3
22+ attempts : 3
23+ on-fail : " echo 'ping failed'"
Original file line number Diff line number Diff line change @@ -6,14 +6,14 @@ Simple ping action / script using curl.
66
77``` sh
88chmod +x ./ping.sh
9- ./ping.sh www.google.com 10
9+ ./ping.sh www.google.com 10 " echo 'ping failed' "
1010```
1111
1212## Docker
1313
1414``` sh
1515docker build -t ping .
16- docker run ping www.google.com 10
16+ docker run ping www.google.com 10 " echo 'ping failed' "
1717```
1818
1919## GitHub Action
2828 with :
2929 url : wwww.google.com
3030 attempts : 10
31+ on-fail : " echo 'ping failed'"
3132` ` `
Original file line number Diff line number Diff line change @@ -12,6 +12,9 @@ inputs:
1212 attempts :
1313 description : " Max attempts"
1414 required : true
15+ on-fail :
16+ description : " Execute bash command on fail"
17+ required : false
1518runs :
1619 using : " docker"
1720 image : " docker://ghcr.io/matiasg19/ping:latest"
Original file line number Diff line number Diff line change 66url=" ${url// localhost/ $hostip } "
77attempts=$2
88attempt=1
9+ onfail=$3
910
1011while [ $attempt -le " $attempts " ]; do
1112 if curl -X GET " $url " ; then
2223
2324echo
2425echo " Could not reach $url after $attempts attempts."
26+ if [ -z " $onfail " ]; then
27+ exit 1
28+ fi
29+ bash -c " $onfail "
2530exit 1
You can’t perform that action at this time.
0 commit comments