-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (39 loc) · 1.25 KB
/
final-newline-checker.yml
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
name: final-newline-checker
on:
pull_request:
# NO paths filter
jobs:
final-newline-checker:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: hakadoriya-actions/[email protected]
id: final-newline-checker
with:
# NOTE: If you want to fail on missing final newline, set this to true
#fail-on-missing: true
#paths: |-
# ^action.yml
# ^missing-final-newline.md
paths-ignore: |-
.*\.p8$
.*p12.*
- name: Submit PR comment if missing final newline
if: ${{ steps.final-newline-checker.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.final-newline-checker.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