GitHub Action to detect files with CRLF, LF, or mixed line endings
Maintain consistent line endings across your repository and prevent platform-induced issues caused by misconfigured Git settings (especially core.autocrlf on Windows).
- ✅ Detect CRLF, LF, or mixed line endings
- 🎯 Flexible file filtering with glob or regex patterns
- 📁 Configurable directory depth scanning
- ⚡ Lightweight implementation using standard POSIX tools
name: Check Line Endings
on: [push, pull_request]
jobs:
check-line-endings:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check for CRLF files
uses: kforeverisback/check-crlf-extended@v2
with:
line_ending_type: CRLF| Parameter | Description | Default |
|---|---|---|
directory |
Directory to scan (relative to $GITHUB_WORKSPACE) |
. |
line_ending_type |
Line ending type to detect: CRLF, LF, or MIXED (case-insensitive) |
crlf |
include_pattern |
Include files matching this pattern | * |
exclude_pattern |
Exclude files matching this pattern | `` |
pattern_type |
Pattern matching type: shell_glob or regex |
shell_glob |
max_dir_depth |
Maximum directory depth to search (root = depth 1) | 999 |
shell_glob: Matches against base filenames only (e.g.,*.txt)regex: Matches against full file paths usingegrepsyntax
Note: When using
regex, see the find manual for pattern syntax.
- name: Check for Windows line endings
uses: kforeverisback/check-crlf-extended@v2
with:
line_ending_type: CRLF- name: Check specific file types with exclusions
uses: kforeverisback/check-crlf-extended@v2
with:
directory: ./src
line_ending_type: LF
include_pattern: '*.{js,ts,py}'
exclude_pattern: '*.min.*'
pattern_type: shell_glob- name: Check with regex exclusions
uses: kforeverisback/check-crlf-extended@v2
with:
line_ending_type: MIXED
exclude_pattern: '.*(test|spec).*\.(js|ts)$'
pattern_type: regex- name: Check line endings (allow failures)
uses: kforeverisback/check-crlf-extended@v2
continue-on-error: true
with:
directory: ./docs
line_ending_type: MIXEDThis action uses standard POSIX utilities (find, egrep, hexdump) to:
- Scan the specified directory (excluding
.gitby default) - Apply include/exclude patterns to filter files
- Analyze line endings in matching files
- Report files that match the specified line ending type
Exit Behavior:
- Returns exit code
0when no matching files are found - Returns non-zero exit code when matching files are detected (fails the workflow step unless
continue-on-error: true)
- Git attributes for line ending control
- GitHub's guide to Git line endings
- Understanding line endings
Built upon erclu/check-crlf with extended functionality and enhanced logging capabilities.