Skip to content

Commit 3ceed62

Browse files
committed
sort input
1 parent 50cc22a commit 3ceed62

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

action.sh

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ for MY_FILE in "${MY_FILES[@]}"; do
5151
fi
5252
done
5353

54+
# Retry wait time in secounds
55+
WAIT_SEC=10
56+
5457
#
5558
# INPUT
5659
#
@@ -59,25 +62,32 @@ done
5962
# https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions#inputs
6063
# When you specify an input, GitHub creates an environment variable for the input with the name INPUT_<VARIABLE_NAME>.
6164

62-
# Set maximal retries * 10 seconds for Hetzner Server creation via the Hetzer Cloud API (default: 360 [1 hour])
65+
# Set maximum retries * WAIT_SEC (10 sec) for Hetzner Server creation via the Hetzer Cloud API (default: 360 [1 hour])
6366
# If INPUT_CREATE_WAIT is set, use its value; otherwise, use "360".
6467
MY_CREATE_WAIT=${INPUT_CREATE_WAIT:-360}
6568
if [[ ! "$MY_CREATE_WAIT" =~ ^[0-9]+$ ]]; then
66-
exit_with_failure "The maximum wait time (retries) for Hetzner Server creation via the Hetzer Cloud API must be an integer!"
69+
exit_with_failure "The maximum retries for Hetzner Server creation via the Hetzer Cloud API must be an integer!"
6770
fi
6871

69-
# Set maximal retries * 10 seconds for Hetzner Server deletion via the Hetzer Cloud API (default: 360 [1 hour])
72+
# Set maximum retries * WAIT_SEC (10 sec) for Hetzner Server deletion via the Hetzer Cloud API (default: 360 [1 hour])
7073
# If INPUT_DELETE_WAIT is set, use its value; otherwise, use "360".
7174
MY_DELETE_WAIT=${INPUT_DELETE_WAIT:-360}
7275
if [[ ! "$MY_DELETE_WAIT" =~ ^[0-9]+$ ]]; then
73-
exit_with_failure "The maximum wait time (retries) for Hetzner Server deletion via the Hetzer Cloud API must be an integer!"
76+
exit_with_failure "The maximum retries for Hetzner Server deletion via the Hetzer Cloud API must be an integer!"
7477
fi
7578

76-
# Set the Hetzner Cloud API token.
77-
# Retrieves the value from the INPUT_HCLOUD_TOKEN environment variable.
78-
MY_HETZNER_TOKEN=${INPUT_HCLOUD_TOKEN}
79-
if [[ -z "$MY_HETZNER_TOKEN" ]]; then
80-
exit_with_failure "Hetzner Cloud API token is not set."
79+
# Enable IPv4 (default: false)
80+
# If INPUT_ENABLE_IPV4 is set, use its value; otherwise, use "false".
81+
MY_ENABLE_IPV4=${INPUT_ENABLE_IPV4:-"true"}
82+
if [[ "$MY_ENABLE_IPV4" != "true" && "$MY_ENABLE_IPV4" != "false" ]]; then
83+
exit_with_failure "Enable IPv4 must be 'true' or 'false'."
84+
fi
85+
86+
# Enable IPv6 (default: true)
87+
# If INPUT_ENABLE_IPV6 is set, use its value; otherwise, use "true".
88+
MY_ENABLE_IPV6=${INPUT_ENABLE_IPV6:-"true"}
89+
if [[ "$MY_ENABLE_IPV6" != "true" && "$MY_ENABLE_IPV6" != "false" ]]; then
90+
exit_with_failure "Enable IPv6 must be 'true' or 'false'."
8191
fi
8292

8393
# Set the GitHub Personal Access Token (PAT).
@@ -100,27 +110,11 @@ MY_GITHUB_REPOSITORY_OWNER_ID=${GITHUB_REPOSITORY_OWNER_ID:-"0"}
100110
# Set The ID of the repository (used for Hetzner Cloud Server label).
101111
MY_GITHUB_REPOSITORY_ID=${GITHUB_REPOSITORY_ID:-"0"}
102112

103-
# Specify here which mode you want to use (default: create):
104-
# - create : Create a new runner
105-
# - delete : Delete the previously created runner
106-
# If INPUT_MODE is set, use its value; otherwise, use "create".
107-
MY_MODE=${INPUT_MODE:-"create"}
108-
if [[ "$MY_MODE" != "create" && "$MY_MODE" != "delete" ]]; then
109-
exit_with_failure "Mode must be 'create' or 'delete'."
110-
fi
111-
112-
# Enable IPv4 (default: false)
113-
# If INPUT_ENABLE_IPV4 is set, use its value; otherwise, use "false".
114-
MY_ENABLE_IPV4=${INPUT_ENABLE_IPV4:-"true"}
115-
if [[ "$MY_ENABLE_IPV4" != "true" && "$MY_ENABLE_IPV4" != "false" ]]; then
116-
exit_with_failure "Enable IPv4 must be 'true' or 'false'."
117-
fi
118-
119-
# Enable IPv6 (default: true)
120-
# If INPUT_ENABLE_IPV6 is set, use its value; otherwise, use "true".
121-
MY_ENABLE_IPV6=${INPUT_ENABLE_IPV6:-"true"}
122-
if [[ "$MY_ENABLE_IPV6" != "true" && "$MY_ENABLE_IPV6" != "false" ]]; then
123-
exit_with_failure "Enable IPv6 must be 'true' or 'false'."
113+
# Set the Hetzner Cloud API token.
114+
# Retrieves the value from the INPUT_HCLOUD_TOKEN environment variable.
115+
MY_HETZNER_TOKEN=${INPUT_HCLOUD_TOKEN}
116+
if [[ -z "$MY_HETZNER_TOKEN" ]]; then
117+
exit_with_failure "Hetzner Cloud API token is not set."
124118
fi
125119

126120
# Set the image to use for the instance (default: ubuntu-24.04)
@@ -135,6 +129,15 @@ fi
135129
# If INPUT_LOCATION is set, use its value; otherwise, use "nbg1".
136130
MY_LOCATION=${INPUT_LOCATION:-"nbg1"}
137131

132+
# Specify here which mode you want to use (default: create):
133+
# - create : Create a new runner
134+
# - delete : Delete the previously created runner
135+
# If INPUT_MODE is set, use its value; otherwise, use "create".
136+
MY_MODE=${INPUT_MODE:-"create"}
137+
if [[ "$MY_MODE" != "create" && "$MY_MODE" != "delete" ]]; then
138+
exit_with_failure "Mode must be 'create' or 'delete'."
139+
fi
140+
138141
# Set the name of the instance (default: gh-runner-$RANDOM)
139142
# If INPUT_NAME is set, use its value; otherwise, generate a random name using "gh-runner-$RANDOM".
140143
MY_NAME=${INPUT_NAME:-"gh-runner-$RANDOM"}
@@ -174,26 +177,6 @@ if [[ "$MY_PRIMARY_IPV6" != "null" && ! "$MY_PRIMARY_IPV6" =~ ^[0-9]+$ ]]; then
174177
exit_with_failure "The primary IPv6 ID must be 'null' or an integer!"
175178
fi
176179

177-
# Set the server type/instance type (default: cx22)
178-
# If INPUT_SERVER_TYPE is set, use its value; otherwise, use "cx22".
179-
MY_SERVER_TYPE=${INPUT_SERVER_TYPE:-"cx22"}
180-
181-
# Set maximal wait time (retries * 10 sec) for Hetzner Cloud Server (default: 30 [5 min])
182-
# If INPUT_SERVER_WAIT is set, use its value; otherwise, use "30".
183-
MY_SERVER_WAIT=${INPUT_SERVER_WAIT:-"30"}
184-
# Check if MY_RUNNER_WAIT is an integer
185-
if [[ ! "$MY_SERVER_WAIT" =~ ^[0-9]+$ ]]; then
186-
exit_with_failure "The maximum wait time (reties) for a running Hetzner Cloud Server must be an integer!"
187-
fi
188-
189-
# Set the SSH key to use for the instance (default: null)
190-
# If INPUT_SSH_KEY is set, use its value; otherwise, use "null".
191-
MY_SSH_KEY=${INPUT_SSH_KEY:-"null"}
192-
# Check if MY_SSH_KEY is an integer
193-
if [[ "$MY_SSH_KEY" != "null" && ! "$MY_SSH_KEY" =~ ^[0-9]+$ ]]; then
194-
exit_with_failure "The SSH key ID must be 'null' or an integer!"
195-
fi
196-
197180
# Set default GitHub Actions Runner installation directory (default: /actions-runner)
198181
# If INPUT_RUNNER_DIR is set, its value is used. Otherwise, the default value "/actions-runner" is used.
199182
MY_RUNNER_DIR=${INPUT_RUNNER_DIR:-"/actions-runner"}
@@ -211,7 +194,7 @@ if [[ "$MY_RUNNER_VERSION" != "latest" && "$MY_RUNNER_VERSION" != "skip" && ! "$
211194
exit_with_failure "'$MY_RUNNER_VERSION' is not a valid GitHub Actions Runner version! Enter 'latest', 'skip' or the version without 'v'."
212195
fi
213196

214-
# Set maximal wait time (retries * 10 sec) for GitHub Actions Runner registration (default: 60 [10 min])
197+
# Set maximal retries * WAIT_SEC (10 sec) for GitHub Actions Runner registration (default: 60 [10 min])
215198
# If INPUT_RUNNER_WAIT is set, use its value; otherwise, use "60".
216199
MY_RUNNER_WAIT=${INPUT_RUNNER_WAIT:-"60"}
217200
# Check if MY_RUNNER_WAIT is an integer
@@ -220,11 +203,28 @@ if [[ ! "$MY_RUNNER_WAIT" =~ ^[0-9]+$ ]]; then
220203
fi
221204

222205
# Set Hetzner Cloud Server ID
206+
# Check only if mode is delete.
223207
MY_HETZNER_SERVER_ID=${INPUT_SERVER_ID}
224208

225-
# Retry wait time in secounds
226-
WAIT_SEC=10
209+
# Set the server type/instance type (default: cx22)
210+
# If INPUT_SERVER_TYPE is set, use its value; otherwise, use "cx22".
211+
MY_SERVER_TYPE=${INPUT_SERVER_TYPE:-"cx22"}
227212

213+
# Set maximal retries * WAIT_SEC (10 sec) for Hetzner Cloud Server (default: 30 [5 min])
214+
# If INPUT_SERVER_WAIT is set, use its value; otherwise, use "30".
215+
MY_SERVER_WAIT=${INPUT_SERVER_WAIT:-"30"}
216+
# Check if MY_RUNNER_WAIT is an integer
217+
if [[ ! "$MY_SERVER_WAIT" =~ ^[0-9]+$ ]]; then
218+
exit_with_failure "The maximum wait time (reties) for a running Hetzner Cloud Server must be an integer!"
219+
fi
220+
221+
# Set the SSH key to use for the instance (default: null)
222+
# If INPUT_SSH_KEY is set, use its value; otherwise, use "null".
223+
MY_SSH_KEY=${INPUT_SSH_KEY:-"null"}
224+
# Check if MY_SSH_KEY is an integer
225+
if [[ "$MY_SSH_KEY" != "null" && ! "$MY_SSH_KEY" =~ ^[0-9]+$ ]]; then
226+
exit_with_failure "The SSH key ID must be 'null' or an integer!"
227+
fi
228228

229229
#
230230
# DELETE

0 commit comments

Comments
 (0)