Skip to content

Commit f2a7348

Browse files
committed
Make config user-level
1 parent 382076d commit f2a7348

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

manage-ghar

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Mandatory arguments:
129129
RUNNER_PATH
130130
Path to a GitHub Actions Runner directory.
131131
132-
If there is a configuration file $CONFIG_FILE in the runner path, then manage-ghar will use it to populate the following optional arguments:
132+
If there is a configuration file $CONFIG_FILE in the user home directory, then manage-ghar will use it to set the default value of the following optional arguments:
133133
state_path
134134
runner_command
135135
force
@@ -143,6 +143,12 @@ main () {
143143
local runner_command=""
144144
local force=false
145145

146+
# read configuration if available
147+
if [[ -f "$HOME/$CONFIG_FILE" ]]
148+
then
149+
declare "$(env -i "$(cat "$HOME/$CONFIG_FILE")")"
150+
fi
151+
146152
# process optional arguments
147153
while getopts ":hs:r:f" option
148154
do
@@ -181,18 +187,6 @@ main () {
181187
local runner_path
182188
runner_path="$(realpath "$2")"
183189

184-
# read configuration if available
185-
if [[ -f $runner_path/$CONFIG_FILE ]]
186-
then
187-
while read -r line
188-
do
189-
if [[ "$line" == "state_path="* ]] || [[ "$line" == "runner_command="* ]] || [[ "$line" == "force="* ]]
190-
then
191-
declare "$line"
192-
fi
193-
done <"$runner_path/$CONFIG_FILE"
194-
fi
195-
196190
# process state path
197191
if [[ -z $state_path ]]
198192
then

0 commit comments

Comments
 (0)