-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaction.yml
More file actions
35 lines (31 loc) · 1.12 KB
/
action.yml
File metadata and controls
35 lines (31 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
author: Arthri
name: Check Line Endings
description: "Lints text files' line endings."
inputs:
default-eol:
default: lf
description: Specifies the default line ending. The supported values are "lf"(default), "crlf", and "mixed".
required: false
runs:
using: composite
steps:
# NOTE: If this script is updated, then /.github/workflows/i.yml must also be updated
- name: Check Line Endings
shell: bash
env:
DEFAULT_EOL: ${{ inputs.default-eol }}
run: |
exit_code=0
while IFS= read line; do
if [[ $line =~ ^i/([^ ]*)\ +w/[^\ ]*\ +attr/[^$'\t']+$'\t'(.+)$ ]] ; then
index_eol=${BASH_REMATCH[1]}
if [[ $index_eol != $DEFAULT_EOL && $index_eol != 'none' && $index_eol != '-text' && -n $index_eol ]] ; then
echo "::error file=${BASH_REMATCH[2]}::${BASH_REMATCH[2]}: End-of-line sequence in index ($index_eol) must be $DEFAULT_EOL."
exit_code=1
fi
else
echo '::error::Unable to match '"$line"
exit_code=1
fi
done < <(git ls-files --eol)
exit $exit_code