-
Notifications
You must be signed in to change notification settings - Fork 0
Create policy-enforcement.yml #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,68 @@ | ||||||||||||||||||||||||||||||||||||||||||||||
| name: Repository Policy Enforcement | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||||||||||
| branches: [ "main" ] | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||||||||
| pull-requests: read | ||||||||||||||||||||||||||||||||||||||||||||||
| checks: write | ||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||
| checks: write |
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for file in $(git ls-files) will break on filenames containing spaces/newlines and can cause false failures or skipped files. Use a NUL-delimited iteration (e.g., git ls-files -z with a while IFS= read -r -d '' file loop) or another approach that safely handles arbitrary paths.
| for file in $(git ls-files); do | |
| size=$(stat -c%s "$file") | |
| if [ $size -gt $MAX_SIZE ]; then | |
| echo "❌ File $file exceeds 5MB limit" | |
| exit 1 | |
| fi | |
| done | |
| while IFS= read -r -d '' file; do | |
| size=$(stat -c%s "$file") | |
| if [ "$size" -gt "$MAX_SIZE" ]; then | |
| echo "❌ File $file exceeds 5MB limit" | |
| exit 1 | |
| fi | |
| done < <(git ls-files -z) |
Copilot
AI
Mar 26, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This introduces a second policy/structure workflow that overlaps with the existing .github/workflows/validate-repo-structure.yml, but with different requirements (e.g., required dirs list and 5MB vs 100MB file threshold). Having both may create inconsistent enforcement and unexpected CI failures; consider consolidating into one workflow or aligning the policy parameters in a single place.
| # 🔹 Prevent large files (Excel models can get big—control it) | |
| - name: Check for large files | |
| run: | | |
| MAX_SIZE=5000000 | |
| for file in $(git ls-files); do | |
| size=$(stat -c%s "$file") | |
| if [ $size -gt $MAX_SIZE ]; then | |
| echo "❌ File $file exceeds 5MB limit" | |
| exit 1 | |
| fi | |
| done | |
| # 🔹 Ensure required project structure exists | |
| - name: Validate repo structure | |
| run: | | |
| REQUIRED_DIRS=("model" "docs" "screenshots") | |
| for dir in "${REQUIRED_DIRS[@]}"; do | |
| if [ ! -d "$dir" ]; then | |
| echo "❌ Missing required directory: $dir" | |
| exit 1 | |
| fi | |
| done |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This workflow is being added under
.github/workflows/.github/workflows/…, but GitHub Actions only loads workflows from.github/workflows/at the repository root. As-is, this workflow will not run; move/rename it to.github/workflows/policy-enforcement.yml(and remove the extra nested.github/workflowsdirectory if unintended).