-
Notifications
You must be signed in to change notification settings - Fork 126
57 lines (51 loc) ยท 1.93 KB
/
pr-line-lint.yaml
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
name: PR Line Lint
on:
pull_request:
types: [opened, ready_for_review, synchronize]
permissions:
contents: write
pull-requests: write
jobs:
line-ending-check:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get list of changed files
id: changed-files
run: |
changed_files=$(git diff --name-only ${{ github.event.pull_request.base.sha }} ${{ github.sha }})
echo "Changed files:"
echo "$changed_files"
echo "files<<EOF" >> $GITHUB_OUTPUT
echo "$changed_files" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Check for missing newlines
id: newline-check
run: |
readarray -t changed_files <<< "${{ steps.changed-files.outputs.files }}"
files_without_newline=""
for file in "${changed_files[@]}"; do
if [ -f "$file" ] && [ "$(tail -c 1 "$file" | wc -l)" -eq 0 ]; then
files_without_newline+="- ${file}\n" # ํฌ๋งท์ ๋ง์ถ๊ธฐ ์ํด ํ์ผ ์ด๋ฆ์ ๋ฐฑํฑ์ผ๋ก ๊ฐ์๋๋ค.
fi
done
if [ -n "$files_without_newline" ]; then
echo "Files without newline at end:"
echo -e "$files_without_newline"
echo "files<<EOF" >> $GITHUB_OUTPUT
echo -e "$files_without_newline" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
exit 1
fi
- name: Set Job Summary
if: always()
run: |
if [ -n "${{ steps.newline-check.outputs.files }}" ]; then
echo "์๋ ํ์ผ๋ค์ ๊ณต๋ฐฑ ์ค์ ์ถ๊ฐํด์ฃผ์ธ์." >> $GITHUB_STEP_SUMMARY
echo -e "${{ steps.newline-check.outputs.files }}" >> $GITHUB_STEP_SUMMARY
else
echo "๋ชจ๋ ํ์ผ์ด ์ฌ๋ฐ๋ฅด๊ฒ ๊ฐํ ์ฒ๋ฆฌ๋์ด ์์ต๋๋ค." >> $GITHUB_STEP_SUMMARY
fi