File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 22
33VAR_NAME=" $1 "
44ARTIFACT_PATH=" $2 "
5- REAL_PATH=$( printf ' %s' " $ARTIFACT_PATH " )
65
7- if [ -d " $REAL_PATH " ]; then
6+ expand_env_vars () {
7+ local input=" $1 "
8+ local output=" "
9+ local prefix suffix var_name
10+
11+ while [[ " $input " == * ' $' * ]]; do
12+ prefix=" ${input%% \$ * } "
13+ suffix=" ${input#* \$ } "
14+ output+=" $prefix "
15+
16+ if [[ " $suffix " =~ ^\{ ([A-Za-z_][A-Za-z0-9_]* )\} (.* )$ ]]; then
17+ var_name=" ${BASH_REMATCH[1]} "
18+ output+=" ${! var_name-} "
19+ input=" ${BASH_REMATCH[2]} "
20+ elif [[ " $suffix " =~ ^([A-Za-z_][A-Za-z0-9_]* )(.* )$ ]]; then
21+ var_name=" ${BASH_REMATCH[1]} "
22+ output+=" ${! var_name-} "
23+ input=" ${BASH_REMATCH[2]} "
24+ else
25+ output+=' $'
26+ input=" $suffix "
27+ fi
28+ done
29+
30+ printf ' %s' " $output$input "
31+ }
32+
33+ ARTIFACT_PATH=$( expand_env_vars " $ARTIFACT_PATH " )
34+
35+ shopt -s nullglob
36+ OLD_IFS=" $IFS "
37+ IFS=
38+ # Intentionally unquoted: expand artifact path globs after variable substitution.
39+ # shellcheck disable=SC2206
40+ MATCHES=( $ARTIFACT_PATH )
41+ IFS=" $OLD_IFS "
42+ shopt -u nullglob
43+
44+ if [ " ${# MATCHES[@]} " -eq 1 ] && [ -d " ${MATCHES[0]} " ]; then
45+ REAL_PATH=" ${MATCHES[0]} "
846 export " $VAR_NAME " =" $REAL_PATH "
947 echo " $VAR_NAME " =" $REAL_PATH " >> " $GITHUB_ENV "
1048fi
You can’t perform that action at this time.
0 commit comments