Files
team/.gitea/workflows/check-path.yml
liujiayu ccc0c873a1
Some checks failed
检查提交路径权限 / 校验提交路径 (push) Has been cancelled
更新 .gitea/workflows/check-path.yml
2025-09-09 15:25:29 +08:00

30 lines
933 B
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: 检查提交路径权限
on: [push, pull_request]
jobs:
check-path:
name: 校验提交路径
runs-on: gitea-runner
steps:
- name: 拉取代码
uses: actions/checkout@v3
- name: 检查是否修改了他人目录
run: |
# 获取当前用户(优先用 GITEA_USERNAME备用提交者用户名
USERNAME=${GITEA_USERNAME:-$(git log -1 --pretty=format:'%an')}
echo "当前提交用户:$USERNAME"
# 获取所有修改的目录
CHANGED_DIRS=$(git diff --name-only HEAD~1 | xargs -n1 dirname | sort -u)
echo "修改的目录有:$CHANGED_DIRS"
for dir in $CHANGED_DIRS; do
if [[ "$dir" != "$USERNAME" && ! "$dir" =~ ^\. ]]; then
echo "错误:你无权修改 '$dir' 目录!"
exit 1
fi
done
echo "✅ 提交通过路径权限检查。"