@@ -11,39 +11,18 @@ jobs:
11
11
with :
12
12
fetch-depth : 0
13
13
14
- - name : Get list of changed files
15
- id : changed-files
14
+ - name : Find files missing end line break
16
15
run : |
17
- changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }} | jq -R -s -c 'split("\n")[:-1]')
18
- echo "changed_files: $changed_files"
19
- echo "files=$changed_files" >> $GITHUB_OUTPUT
20
-
21
- - name : Check for missing newlines
22
- id : newline-check
23
- run : |
24
- files_without_newline=()
25
- while IFS= read -r file; do
26
- if [ -f "$file" ]; then
27
- last_char=$(tail -c 1 "$file")
28
- if [ -n "$last_char" ]; then
29
- files_without_newline+=("$file")
30
- fi
16
+ files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
17
+ success=true
18
+ for file in $files; do
19
+ if [ "$(tail -c 1 $file | wc -l)" -eq 0 ]; then
20
+ echo "- $file" >> $GITHUB_STEP_SUMMARY
21
+ success=false
31
22
fi
32
- done < <(echo '${{ steps.changed-files.outputs.files }}' | jq -r '.[]')
23
+ done
33
24
34
- if [ ${#files_without_newline[@]} -gt 0 ]; then
35
- json_files=$(printf '%s\n' "${files_without_newline[@]}" | jq -R -s -c 'split("\n")[:-1]')
36
- echo "files_without_newline: $json_files"
37
- echo "files=$json_files" >> $GITHUB_OUTPUT
25
+ if [ "$success" = false ]; then
26
+ echo -e "\n:warning: ์ ํ์ผ๋ค์ ๋์ ๋๋ฝ๋ ์ค ๋ฐ๊ฟ์ ์ถ๊ฐํด ์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY
38
27
exit 1
39
28
fi
40
-
41
- - name : Set Job Summary
42
- if : failure()
43
- run : |
44
- if [ -n '${{ steps.newline-check.outputs.files }}' ]; then
45
- echo "๐ ๏ธ ์๋ ํ์ผ๋ค์ ๊ณต๋ฐฑ ์ค์ ์ถ๊ฐํด์ฃผ์ธ์:" >> $GITHUB_STEP_SUMMARY
46
- echo '${{ steps.newline-check.outputs.files }}' |
47
- jq -r '.[]' |
48
- sed 's/^/- /' >> $GITHUB_STEP_SUMMARY
49
- fi
0 commit comments