Create check-metadata.yml

This commit is contained in:
Kristo Copani 2024-12-29 23:16:48 +02:00 committed by GitHub
parent 2832a1e2c4
commit 78e26d84f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

51
.github/workflows/check-metadata.yml vendored Normal file
View File

@ -0,0 +1,51 @@
name: Check Metadata
'on':
pull_request:
paths:
- '**/*.sh'
jobs:
check-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Check `source` Line in Scripts
shell: bash
run: |
set -e
ERROR_COUNT=0
FILES=$(find . -name "*.sh")
for FILE in $FILES; do
if grep -qF "# Copyright (c) 2021-2024 community-scripts ORG" "$FILE"; then
echo "Check for Copyright metadata passed for: $FILE"
else
echo "Error in $FILE: Copyright metadata missing"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if grep -qF "# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE" "$FILE"; then
echo "Check for License metadata passed for: $FILE"
else
echo "Error in $FILE: License metadata missing"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if grep -q "^# Source: .\+" "$FILE"; then
echo "Check for Source metadata passed for: $FILE"
else
echo "Error in $FILE: Source metadata missing"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
if grep -q "^# Source: .\+" "$FILE"; then
echo "Check for Author metadata passed for: $FILE"
else
echo "Error in $FILE: Author metadata missing"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
done
if [[ "$ERROR_COUNT" -gt 0 ]]; then
echo "$ERROR_COUNT script(s) failed validation."
exit 1
else
echo "All scripts passed."
fi