Skip to content

Commit d4de047

Browse files
committed
add license headers check github workflow
1 parent de4e478 commit d4de047

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

.github/add-license-headers.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
script_path=$(dirname $(realpath $0))/../
3+
4+
function add_license () {
5+
(find "$script_path" -name $1 | grep -v "/bin/" | grep -v "/obj/" )|while read fname; do
6+
line=$(sed -n '2p;3q' "$fname")
7+
if ! [[ "$line" == " * Licensed to Elasticsearch B.V. under one or more contributor" ]] ; then
8+
cat "${script_path}.github/license-header.txt" "$fname" > "${fname}.new"
9+
mv "${fname}.new" "$fname"
10+
fi
11+
done
12+
}
13+
14+
add_license "*.cs"

.github/workflows/license.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: License headers
2+
3+
on: [ pull_request ]
4+
5+
permissions:
6+
contents: read
7+
8+
jobs:
9+
build:
10+
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Check license headers
17+
run: |
18+
./.github/check-license-headers.sh

0 commit comments

Comments
 (0)