Skip to content

Commit

Permalink
added commit hook for checking that license header's year for added f…
Browse files Browse the repository at this point in the history
…iles is the current year

Signed-off-by: Thomas Jaeckle <thomas.jaeckle@bosch.io>
  • Loading branch information
thjaeckle committed Dec 21, 2020
1 parent 55d5ca2 commit e8ff008
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/license-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Copyright (c) 2020 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
name: license-check

on:
# Run build for any PR
pull_request:

jobs:
check-license-header-year:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: jitterbit/get-changed-files@v1
id: the-files
- name: Printing added files
run: |
echo "Added:"
echo "${{ steps.the-files.outputs.added }}"
- name: Ensure license year for added files is the file's creation year
shell: bash
run: |
included_file_endings=".*\.(java|xml|yml|ts|js)"
current_year=$(date +'%Y')
missing_counter=0
for file in ${{ steps.the-files.outputs.added }}; do
if [[ $file =~ $included_file_endings ]]; then
file_creation_year=$(git log --format=%aD $file | tail -1 | awk '{print $4}')
if grep -q "Copyright (c) $file_creation_year Contributors to the Eclipse Foundation" $file; then
printf "\xE2\x9C\x94 $file\n"
else
printf "\xE2\x9D\x8C $file\n\tcopyright header with file creation year '$file_creation_year' is missing in added file\n"
missing_counter=$(expr $missing_counter + 1)
fi
fi
done
exit $missing_counter
10 changes: 10 additions & 0 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright (c) 2020 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
name: java-build

on:
Expand Down
10 changes: 10 additions & 0 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
# Copyright (c) 2020 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License 2.0 which is available at
# http://www.eclipse.org/legal/epl-2.0
#
# SPDX-License-Identifier: EPL-2.0
name: javascript-build

on:
Expand Down

0 comments on commit e8ff008

Please sign in to comment.