Skip to content

Commit fba671f

Browse files
committed
ci: add line ending check workflow for current pr
1 parent ca6a63c commit fba671f

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
name: PR Line Lint
2+
3+
on:
4+
pull_request:
5+
types: [opened, ready_for_review, synchronize]
6+
7+
permissions:
8+
contents: write
9+
pull-requests: write
10+
11+
jobs:
12+
line-ending-check:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Get list of changed files
21+
id: changed-files
22+
run: |
23+
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
24+
echo "Changed files:"
25+
echo "$changed_files"
26+
echo "files<<EOF" >> $GITHUB_OUTPUT
27+
echo "$changed_files" >> $GITHUB_OUTPUT
28+
echo "EOF" >> $GITHUB_OUTPUT
29+
30+
- name: Check for missing newlines
31+
id: newline-check
32+
run: |
33+
readarray -t changed_files <<< "${{ steps.changed-files.outputs.files }}"
34+
files_without_newline=""
35+
for file in "${changed_files[@]}"; do
36+
if [ -f "$file" ] && [ "$(tail -c 1 "$file" | wc -l)" -eq 0 ]; then
37+
files_without_newline+="- ${file}\n" # ํฌ๋งท์„ ๋งž์ถ”๊ธฐ ์œ„ํ•ด ํŒŒ์ผ ์ด๋ฆ„์„ ๋ฐฑํ‹ฑ์œผ๋กœ ๊ฐ์Œ‰๋‹ˆ๋‹ค.
38+
fi
39+
done
40+
if [ -n "$files_without_newline" ]; then
41+
echo "Files without newline at end:"
42+
echo -e "$files_without_newline"
43+
echo "files<<EOF" >> $GITHUB_OUTPUT
44+
echo -e "$files_without_newline" >> $GITHUB_OUTPUT
45+
echo "EOF" >> $GITHUB_OUTPUT
46+
exit 1
47+
fi
48+
49+
- name: Set Job Summary
50+
if: always()
51+
run: |
52+
if [ -n "${{ steps.newline-check.outputs.files }}" ]; then
53+
echo "์•„๋ž˜ ํŒŒ์ผ๋“ค์— ๊ณต๋ฐฑ ์ค„์„ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”." >> $GITHUB_STEP_SUMMARY
54+
echo -e "${{ steps.newline-check.outputs.files }}" >> $GITHUB_STEP_SUMMARY
55+
else
56+
echo "๋ชจ๋“  ํŒŒ์ผ์ด ์˜ฌ๋ฐ”๋ฅด๊ฒŒ ๊ฐœํ–‰ ์ฒ˜๋ฆฌ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค." >> $GITHUB_STEP_SUMMARY
57+
fi

0 commit comments

Comments
ย (0)