ci: add line ending check workflow for current pr #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |