Commit 00356c0 1 parent 0aa70e2 commit 00356c0 Copy full SHA for 00356c0
File tree 1 file changed +30
-0
lines changed
1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Check for Gitignored Files
2
+
3
+ on :
4
+ push :
5
+ branches :
6
+ - ' **' # Run on all branches
7
+ pull_request :
8
+
9
+ jobs :
10
+ check-gitignored-files :
11
+ runs-on : ubuntu-latest
12
+
13
+ steps :
14
+ - name : Checkout code
15
+ uses : actions/checkout@v3
16
+
17
+ - name : Check for gitignored files in commit
18
+ run : |
19
+ # List all files in the commit
20
+ git diff --name-only --cached > committed_files.txt
21
+
22
+ # Check if any of the committed files are ignored by .gitignore
23
+ git check-ignore -v $(cat committed_files.txt) > ignored_files.txt || true
24
+
25
+ # Fail if there are any ignored files
26
+ if [[ -s ignored_files.txt ]]; then
27
+ echo "The following files are gitignored but committed:"
28
+ cat ignored_files.txt
29
+ exit 1
30
+ fi
You can’t perform that action at this time.
0 commit comments