check current copyright year in modified files (#4868)

On PR, ensure current year is listed in copyright of modified files.
Runs on Linux GitHub.
This commit is contained in:
Etan Kissling 2023-04-27 17:55:11 +02:00 committed by GitHub
parent 964417d8ba
commit 351f043a61
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

View File

@ -1,3 +1,10 @@
# beacon_chain
# Copyright (c) 2020-2023 Status Research & Development GmbH
# Licensed and distributed under either of
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
# at your option. This file may not be copied, modified, or distributed except according to those terms.
name: CI
on:
push:
@ -54,6 +61,31 @@ jobs:
# with:
# submodules: true
- name: Check copyright year (Linux)
if: runner.os == 'Linux'
run: |
excluded_extensions="md|png"
base_branch=$(jq -r '.pull_request.base.ref' "$GITHUB_EVENT_PATH")
git fetch origin "$base_branch" 2>/dev/null
modified_files=$(git diff --name-only --diff-filter=d "origin/$base_branch" HEAD | grep -vE '\.('$excluded_extensions')$')
current_year=$(date +"%Y")
outdated_files=()
for file in $modified_files; do
if ! grep -qE "Copyright \(c\) .*$current_year Status Research & Development GmbH" "$file"; then
outdated_files+=("$file")
fi
done
if (( ${#outdated_files[@]} )); then
echo "The following files do not have an up-to-date copyright year:"
for file in "${outdated_files[@]}"; do
echo "- $file"
done
exit 1
fi
- name: MSYS2 (Windows amd64)
if: runner.os == 'Windows' && matrix.target.cpu == 'amd64'
uses: msys2/setup-msys2@v2