Skip to content

A GitHub Actions workflow to check missing final newline in files.

License

Notifications You must be signed in to change notification settings

hakadoriya-actions/final-newline-checker

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

20 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

final-newline-checker

A workflow to check missing final newline.

example

name: example

on:
  pull_request:

jobs:
  missing-final-newline:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    steps:
      - uses: hakadoriya-actions/[email protected]
        id: missing-final-newline
        with:
          # NOTE: If you want to fail on missing final newline, set this to true
          #fail-on-missing: true
          paths-ignore: |-
            ^README.md$
      - name: Submit PR comment if missing final newline
        if: ${{ steps.missing-final-newline.outputs.missing == 'true' }}
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          # Create comment body
          cat <<EOF | perl -pe 's/\\n/\n/g' | tee /tmp/gh-pr-comment-body.md
          ## 🚨 Missing final newline

          The following files are missing final newline.

          \`\`\`
          ${{ steps.missing-final-newline.outputs.missing-files }}
          \`\`\`
          EOF
          # Submit PR comment
          gh pr comment ${{ github.event.pull_request.number }} --body-file /tmp/gh-pr-comment-body.md
          # fail the workflow
          exit 1

About

A GitHub Actions workflow to check missing final newline in files.

Resources

License

Stars

Watchers

Forks