From 00356c077ace507fa7f3a03bb12388793542621c Mon Sep 17 00:00:00 2001 From: Martin Thoma Date: Sun, 8 Dec 2024 10:28:23 +0100 Subject: [PATCH] DEV: CI checks for gitignored files (#81) --- .github/workflows/check-gitignored-files.yml | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/check-gitignored-files.yml diff --git a/.github/workflows/check-gitignored-files.yml b/.github/workflows/check-gitignored-files.yml new file mode 100644 index 0000000..e947e6c --- /dev/null +++ b/.github/workflows/check-gitignored-files.yml @@ -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