Skip to content

DEV: CI checks for gitignored files #81

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

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/check-gitignored-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Check for Gitignored Files

on:
push:
branches:
- '**' # Run on all branches
pull_request:

jobs:
check-gitignored-files:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Check for gitignored files in commit
run: |
# List all files in the commit
git diff --name-only --cached > committed_files.txt

# Check if any of the committed files are ignored by .gitignore
git check-ignore -v $(cat committed_files.txt) > ignored_files.txt || true

# Fail if there are any ignored files
if [[ -s ignored_files.txt ]]; then
echo "The following files are gitignored but committed:"
cat ignored_files.txt
exit 1
fi
Loading