Skip to content

Create policy-enforcement.yml - #5

Merged
mr-adonis-jimenez merged 1 commit into
mainfrom
chore/policy-enforcement
Mar 26, 2026
Merged

Create policy-enforcement.yml#5
mr-adonis-jimenez merged 1 commit into
mainfrom
chore/policy-enforcement

Conversation

@mr-adonis-jimenez

Copy link
Copy Markdown
Owner

No description provided.

@gemini-code-assist

Copy link
Copy Markdown

Note

Gemini is unable to generate a summary for this pull request due to the file types involved not being currently supported.

@mr-adonis-jimenez
mr-adonis-jimenez merged commit 24a95b4 into main Mar 26, 2026
2 of 3 checks passed
@mr-adonis-jimenez
mr-adonis-jimenez deleted the chore/policy-enforcement branch March 26, 2026 14:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a GitHub Actions workflow intended to enforce repository policies (branch naming, file size limits, required directories/files) on PRs and pushes to main.

Changes:

  • Add a new “Repository Policy Enforcement” workflow.
  • Enforce branch naming convention for PR branches.
  • Validate file-size limits and required repository structure/README.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1 to +3
name: Repository Policy Enforcement

on:

Copilot AI Mar 26, 2026

Copy link

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/workflows directory if unintended).

Copilot uses AI. Check for mistakes.
permissions:
contents: read
pull-requests: read
checks: write

Copilot AI Mar 26, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workflow requests checks: write permission, but none of the steps call the Checks API or otherwise need write access. Consider removing it (and any other unused permissions) to follow least-privilege for GitHub Actions tokens.

Suggested change
checks: write

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +46
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

Copilot AI Mar 26, 2026

Copy link

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.

Suggested change
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 uses AI. Check for mistakes.
Comment on lines +36 to +58
# 🔹 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

Copilot AI Mar 26, 2026

Copy link

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.

Suggested change
# 🔹 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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants