Skip to content

Commit 93b3f6f

Browse files
committed
Fix by ai
1 parent 7cdc586 commit 93b3f6f

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

.github/workflows/CI.yml

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -74,53 +74,72 @@ jobs:
7474
OUTPUT_VAR_NAME: DEPS_COMPILER_ARGS
7575
run: |
7676
handleDep() {
77-
echo "dep: '$1'"
77+
local dep="$1"
78+
echo "dep: '$dep'"
7879
79-
REPO="${1%%@*}"
80+
local REPO="${dep%%@*}"
8081
echo "- REPO='$REPO'"
8182
82-
TAG="${1#*@}"
83+
local TAG="${dep#*@}"
8384
TAG="${TAG%%:*}"
8485
echo "- TAG='$TAG'"
8586
86-
OVERRIDE_INCLUDE_PATH="${TAG#*:}"
87+
local OVERRIDE_INCLUDE_PATH="${TAG#*:}"
8788
echo "- OVERRIDE_INCLUDE_PATH='$OVERRIDE_INCLUDE_PATH'"
88-
89+
8990
9091
if [ -z "$REPO" ]; then
9192
echo "No repo provided"
9293
exit 1
9394
fi
9495
95-
INIT_PWD=$(pwd)
96-
mkdir -p dep/${REPO}
97-
cd dep/${REPO}
96+
local INIT_PWD=$(pwd)
97+
mkdir -p dep/"${REPO}"
98+
cd dep/"${REPO}"
9899
99100
if [ -z "$2" ]; then
100-
TAG=`curl --silent https://api.github.com/repos/${REPO}/releases/latest | jq .tag_name -r`
101+
TAG=$(curl --silent "https://api.github.com/repos/${REPO}/releases/latest" | jq -r .tag_name)
101102
else
102-
TAG=$2
103+
TAG="$2"
103104
fi
104105
105-
wget https://github.com/${REPO}/archive/refs/tags/${TAG}.zip
106-
7z x ${TAG}.zip
106+
echo "Downloading tag: $TAG"
107+
108+
wget "https://github.com/${REPO}/archive/refs/tags/${TAG}.zip"
109+
7z x "${TAG}.zip"
107110
108-
REPO_NAME=`echo "${REPO}" | grep -Po '(?<=\/).+'`
109-
INCLUDE_PATH='$(pwd)/${REPO_NAME}-${TAG}/${OVERRIDE_INCLUDE_PATH:-amxmodx/scripting/include}'
111+
# Безопасный REPO_NAME без grep -P
112+
local REPO_NAME="${REPO#*/}"
113+
echo "- REPO_NAME='$REPO_NAME'"
110114
111-
echo "${OUTPUT_VAR_NAME}=\"\${${OUTPUT_VAR_NAME}} -i\\\"${INCLUDE_PATH}\\\"\""
112-
echo "${OUTPUT_VAR_NAME}=\"\${${OUTPUT_VAR_NAME}} -i\\\"${INCLUDE_PATH}\\\"\"" >> $GITHUB_ENV
115+
local INCLUDE_PATH="$(pwd)/${REPO_NAME}-${TAG}/${OVERRIDE_INCLUDE_PATH:-amxmodx/scripting/include}"
116+
echo "- INCLUDE_PATH='$INCLUDE_PATH'"
113117
114-
cd $INIT_PWD
118+
# Возвращаем путь для аппенда
119+
echo "-i\\\"${INCLUDE_PATH}\\\""
120+
121+
cd "$INIT_PWD"
122+
echo "\n\n"
115123
}
124+
export -f handleDep
125+
126+
# Инициализируем локальную переменную
127+
local_args=""
128+
129+
deps=$(echo "${DEPS_LIST}" | tr ";" "\n")
130+
echo "deps: \n${deps}"
131+
echo "\n\n"
132+
133+
while IFS= read -r dep; do
134+
if [ -n "$dep" ]; then
135+
path_arg=$(handleDep "$dep")
136+
local_args="${local_args} ${path_arg}"
137+
fi
138+
done <<< "$deps"
116139
117-
deps=$(echo ${DEPS_LIST} | tr ";" "\n")
118-
echo "DEPS_LIST: ${DEPS_LIST}"
119-
echo "deps: ${deps}"
120-
for dep in $deps
121-
do
122-
handleDep $dep
123-
done
140+
# Записываем один раз в env
141+
echo "$OUTPUT_VAR_NAME=\"$local_args\"" >> $GITHUB_ENV
142+
echo "Final $OUTPUT_VAR_NAME: $local_args"
124143
125144
- name: Setup AMXXPawn Compiler
126145
uses: wopox1337/setup-amxxpawn@v1.1.0

0 commit comments

Comments
 (0)