Skip to content

Commit bf28a68

Browse files
committed
Feature: Improve sleep time
1 parent 56e2c3b commit bf28a68

File tree

1 file changed

+18
-11
lines changed

1 file changed

+18
-11
lines changed

.github/workflows/ssh.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ on:
66
SSH_MAX_TIME:
77
description: 'SSH session max duration (1–6 hrs)'
88
required: true
9-
default: 2
9+
default: '2h'
1010
type: choice
1111
options:
12-
- 1
13-
- 2
14-
- 3
15-
- 4
16-
- 5
17-
- 6
12+
- '1h'
13+
- '2h'
14+
- '3h'
15+
- '4h'
16+
- '5h'
17+
- '5h45m'
1818
NGROK_AUTH_TOKEN:
1919
description: 'ngrok API auth token'
2020
required: true
@@ -136,7 +136,14 @@ jobs:
136136
- name: Keep session alive
137137
run: |
138138
trap '' SIGINT SIGTERM
139-
HOURS=${{ github.event.inputs.SSH_MAX_TIME }}
140-
SECONDS=$((HOURS * 3600))
141-
echo "⏳ Keeping SSH session alive for $HOURS hour(s) ($SECONDS seconds)"
142-
sleep "$SECONDS" || true
139+
RAW_TIME="${{ github.event.inputs.SSH_MAX_TIME }}"
140+
case "$RAW_TIME" in
141+
1h) SLEEP_TIME=$((1 * 3600)) ;;
142+
2h) SLEEP_TIME=$((2 * 3600)) ;;
143+
3h) SLEEP_TIME=$((3 * 3600)) ;;
144+
4h) SLEEP_TIME=$((4 * 3600)) ;;
145+
5h) SLEEP_TIME=$((5 * 3600)) ;;
146+
5h45m) SLEEP_TIME=$((5 * 3600 + 45 * 60)) ;;
147+
esac
148+
echo "⏳ Keeping SSH session alive for $RAW_TIME ($SLEEP_TIME seconds)"
149+
sleep "$SLEEP_TIME" || true

0 commit comments

Comments
 (0)