Files
team/.gitea/workflows/check-path.yml
Workflow config file is invalid. Please check your config file: yaml: line 14: mapping values are not allowed in this context

30 lines
867 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: 校验提交路径
environment: gitea
runs-on: gitea-runner
steps:
- name: 拉取代码
uses: actions/checkout@v3
- name: 设置用户名(获取 GITEA_USERNAME
run: echo "用户名是: $GITEA_USERNAME"
- name: 检查是否修改了他人目录
run: |
# 获取所有修改目录
CHANGED_DIRS=$(git diff --name-only HEAD~1 | xargs -n1 dirname | sort -u)
echo "修改的目录为:$CHANGED_DIRS"
for dir in $CHANGED_DIRS; do
if [[ "$dir" != "$GITEA_USERNAME" && ! "$dir" =~ ^\. ]]; then
echo "错误:你不能修改别人($dir的目录"
exit 1
fi
done
echo "✅ 提交路径符合权限要求。"