Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Github action to check metadata lines in scripts. #1110

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/check-metadata.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Check Metadata
on:
pull_request:
paths:
- '/ct/*.sh'
- '/install/*.sh'
jobs:
check-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Check Metadata Lines in Scripts
shell: bash
michelroegl-brunner marked this conversation as resolved.
Show resolved Hide resolved
run: |
set -e
ERROR_COUNT=0
FILES=$(find . -name "*.sh")

for FILE in $FILES; do
if [[ "$(sed -n '3p' "$FILE")" == "# Copyright (c) 2021-2024 community-scripts ORG" ]]; then
echo "Check for Copyright metadata passed for line 3 in: $FILE"
else
echo "Error in $FILE: Copyright metadata missing or not on line 3"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi

if sed -n '4p' "$FILE" | grep -qE "^# Author: .+"; then
echo "Check for Author metadata passed for line 4 in: $FILE"
else
echo "Error in $FILE: Author metadata missing or invalid on line 4"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi

if [[ "$(sed -n '5p' "$FILE")" == "# License: MIT | https://github.com/community-scripts/ProxmoxVE/raw/main/LICENSE" ]]; then
echo "Check for License metadata passed for line 5 in: $FILE"
else
echo "Error in $FILE: License metadata missing or not on line 5"
ERROR_COUNT=$((ERROR_COUNT + 1))
fi
MickLesk marked this conversation as resolved.
Show resolved Hide resolved

if sed -n '6p' "$FILE" | grep -qE "^# Source: .+"; then
echo "Check for Source metadata passed for line 6 in: $FILE"
else
echo "Error in $FILE: Source metadata missing or invalid on line 6"
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
Loading