Skip to content

Commit e844b47

Browse files
committed
Check args are non empty before iteration, use read
1 parent e8ed91a commit e844b47

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

.github/workflows/ci-command-configs.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,17 +81,20 @@ jobs:
8181
8282
# Parse comment into command args
8383
comment='${{ github.event.comment.body }}'
84-
command=$(head -n1 <<< "$comment")
84+
read -r command <<< "$comment"
8585
args=${command#!update-configs}
8686
8787
# Processing args
8888
# FIXME: Wouldn't handle positional args, if they were part of the command syntax
89-
for arg in $args; do
90-
case $arg in
91-
profile=*) profile="${arg#profile=}" ;;
92-
*) echo "::error::Unknown argument '$arg'. Usage: $USAGE"; exit 1;;
93-
esac
94-
done
89+
# If there isn't anything after !update-configs, args will be empty (or erroneously spaces, which we strip)
90+
if [ -n "${args// }" ]; then
91+
for arg in $args; do
92+
case $arg in
93+
profile=*) profile="${arg#profile=}" ;;
94+
*) echo "::error::Unknown argument '$arg'. Usage: $USAGE"; exit 1;;
95+
esac
96+
done
97+
fi
9598
9699
# Output processed args
97100
echo "profile=$profile" >> $GITHUB_OUTPUT

0 commit comments

Comments
 (0)