-
Notifications
You must be signed in to change notification settings - Fork 320
48 lines (42 loc) · 1.16 KB
/
headerchecker.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
44
45
46
47
48
---
name: Check for Headers in Source Code
on:
push:
branches: ['renovate/**']
pull_request:
branches: [main]
jobs:
build:
name: Check for Headers
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- id: files
uses: jitterbit/get-changed-files@v1
with:
format: 'json'
token: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true
- name: Check for headers
run: |
ok=1
readarray -t files <<<"$(jq -r '.[]' <<<'${{ steps.files.outputs.added_modified }}')"
for file in ${files[@]}; do
if [[ ($file == *".java") ]]; then
if ! grep -q Copyright "$file"; then
ok=0
echo "Copyright header not found in $file"
fi
fi
done
if [[ $ok == 0 ]]; then
exit 1
else
GREEN="\e[32m"
echo -e "${GREEN}All changed & added files have been scanned. Result: no headers are missing.${ENDCOLOR}"
fi