File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 24
24
- uses : actions/checkout@master
25
25
- name : Checks for License file
26
26
run : |
27
- if ! [[ -f "LICENSE" || -f "License.txt" || -f "LICENSE.md" ]]; then exit 1; fi
27
+ expected_license_files=("LICENSE" "LICENSE.txt" "LICENSE.md" "License.txt")
28
+ license_file_found=false
29
+ current_year=$(date +"%Y")
30
+
31
+ for license_file in "${expected_license_files[@]}"; do
32
+ if [ -f "$license_file" ]; then
33
+ license_file_found=true
34
+ # check the license file for the current year, if not exists, exit with error
35
+ if ! grep -q "$current_year" "$license_file"; then
36
+ echo "License file $license_file does not contain the current year."
37
+ exit 2
38
+ fi
39
+ break
40
+ fi
41
+ done
42
+
43
+ if [ "$license_file_found" = false ]; then
44
+ echo "No license file found. Please add a license file to the repository."
45
+ exit 1
46
+ fi
You can’t perform that action at this time.
0 commit comments