modified: .github/workflows/md-check.yml
Check cpp / md pair and analyze cpp / Check md headers and analyze cpp (push) Successful in 30s
Check cpp / md pair and analyze cpp / Check md headers and analyze cpp (push) Successful in 30s
This commit is contained in:
1 parent
3bb0db00ed
commit
a7e0f333a2
1 file changed
+5
-13
@@ -2,9 +2,6 @@ name: Check cpp / md pair and analyze cpp
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
paths:
|
|
||||||
- '**/*.cpp'
|
|
||||||
- '**/*.md'
|
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
@@ -32,7 +29,8 @@ jobs:
|
|||||||
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMR "$BEFORE" "$AFTER" || true)
|
CHANGED_FILES=$(git diff --name-only --diff-filter=ACMR "$BEFORE" "$AFTER" || true)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mapfile -t CPP_FILES < <(printf '%s\n' "$CHANGED_FILES" | grep -E '\.cpp$' || true)
|
# 仅保留根目录下的 .cpp 文件(路径中不含 "/")
|
||||||
|
mapfile -t CPP_FILES < <(printf '%s\n' "$CHANGED_FILES" | grep -E '^[^/]+\.cpp$' || true)
|
||||||
|
|
||||||
: > /tmp/cpp_files.txt
|
: > /tmp/cpp_files.txt
|
||||||
for f in "${CPP_FILES[@]}"; do
|
for f in "${CPP_FILES[@]}"; do
|
||||||
@@ -40,25 +38,19 @@ jobs:
|
|||||||
done
|
done
|
||||||
|
|
||||||
if [ "${#CPP_FILES[@]}" -eq 0 ]; then
|
if [ "${#CPP_FILES[@]}" -eq 0 ]; then
|
||||||
echo "本次 push 没有 .cpp 文件,跳过检查与分析。"
|
echo "本次 push 没有根目录下的 .cpp 文件,跳过检查与分析。"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "本次 push 中的 .cpp 文件:"
|
echo "本次 push 中根目录下的 .cpp 文件:"
|
||||||
printf ' %s\n' "${CPP_FILES[@]}"
|
printf ' %s\n' "${CPP_FILES[@]}"
|
||||||
|
|
||||||
EXIT_CODE=0
|
EXIT_CODE=0
|
||||||
for cpp_file in "${CPP_FILES[@]}"; do
|
for cpp_file in "${CPP_FILES[@]}"; do
|
||||||
[ -z "$cpp_file" ] && continue
|
[ -z "$cpp_file" ] && continue
|
||||||
|
|
||||||
dir=$(dirname "$cpp_file")
|
|
||||||
base=$(basename "$cpp_file" .cpp)
|
base=$(basename "$cpp_file" .cpp)
|
||||||
|
md_file="${base}.md"
|
||||||
if [ "$dir" = "." ]; then
|
|
||||||
md_file="${base}.md"
|
|
||||||
else
|
|
||||||
md_file="${dir}/${base}.md"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -f "$md_file" ]; then
|
if [ -f "$md_file" ]; then
|
||||||
FIRST_LINE=$(head -n 1 "$md_file")
|
FIRST_LINE=$(head -n 1 "$md_file")
|
||||||
|
|||||||
Reference in new issue
Block a user