This repository has been archived by the owner on Oct 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
77 lines (73 loc) · 2.09 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: 'actions-easyconnect'
description: 'run your scripts in easyconnect!'
inputs:
CLI_OPTS:
description: '-d {vpnUrl} -u {username} -p {password}'
required: true
SCRIPT:
description: 'Your script'
required: false
SLEEP_AFTER_LOGIN:
description: "How many seconds to sleep after login"
required: false
default: 5
RETRY:
description: "How many times to retry after error"
required: false
default: 1
EXPECTED_EXIT_CODE:
description: "Which exception code (not 0) is your expectation"
required: false
default: 0
EXPECTED_IGNORE_CODE:
description: "Which exception code (not 0) you want to ignore"
required: false
default: 255
runs:
using: 'composite'
steps:
- id: install-easyconnect
run: sudo bash ${{ github.action_path }}/prerequisite.sh
shell: bash
- id: run-it
shell: bash
env:
CLI_OPTS: ${{ inputs.CLI_OPTS }}
run: |
cnt=0
set +e
for _retry in {1..${{ inputs.RETRY }}}
do
echo "try_$_retry" `date`
bash ${{ github.action_path }}/start.sh
exitCode=$?
if [[ $exitCode != 0 ]]
then
cnt=$(($cnt+1))
echo "connection error code: "$exitCode
bash ${{ github.action_path }}/stop.sh
sleep 3
continue
fi
sleep ${{ inputs.SLEEP_AFTER_LOGIN }}
if [[ $exitCode == 0 ]]
then
${{ inputs.SCRIPT }}
exitCode=$?
echo "user code exit code: "$exitCode
if [[ $exitCode == 0 || $exitCode == ${{ inputs.EXPECTED_EXIT_CODE }} ]]
then
bash ${{ github.action_path }}/stop.sh
break
else
cnt=$(($cnt+1))
bash ${{ github.action_path }}/stop.sh
fi
fi
done
set -e
if [[ $exitCode != ${{ inputs.EXPECTED_IGNORE_CODE }} && $cnt == ${{ inputs.RETRY }} || $exitCode == ${{ inputs.EXPECTED_EXIT_CODE }} ]]
then
echo "hit error:"$exitCode
exit -1
fi