-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into topic-composer-plugin-v3
- Loading branch information
Showing
3,488 changed files
with
5,625 additions
and
6,163 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: Copyright Check | ||
|
||
on: | ||
pull_request: | ||
push: | ||
|
||
jobs: | ||
check-copyright: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Skip OM commits | ||
if: github.event_name == 'push' | ||
id: skip_check | ||
run: | | ||
COMMIT_MSG=$(git log --format=%B -n 1 ${{ github.sha }}) | ||
if [[ "$COMMIT_MSG" =~ ^OM\ PR ]]; then | ||
echo "skip=true" >> $GITHUB_OUTPUT | ||
else | ||
echo "skip=false" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Get changed files | ||
id: changed-files | ||
if: github.event_name == 'pull_request' || steps.skip_check.outputs.skip != 'true' | ||
uses: tj-actions/changed-files@v45 | ||
|
||
- name: Check copyright in modified files | ||
if: github.event_name == 'pull_request' || steps.skip_check.outputs.skip != 'true' | ||
shell: bash | ||
run: | | ||
# Get current year | ||
CURRENT_YEAR=$(date +%Y) | ||
# Initialize error flag | ||
ERROR=0 | ||
# Loop through each modified file | ||
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do | ||
# Skip if file doesn't exist (was deleted) | ||
if [ ! -f "$file" ]; then | ||
continue | ||
fi | ||
# Only check files with specific extensions | ||
extension="${file##*.}" | ||
if ! [[ "${extension,,}" =~ ^(css|js|php|phtml|template|xml)$ ]]; then | ||
continue | ||
fi | ||
# Check if file contains the copyright string with current year | ||
# Pattern matches either: | ||
# @copyright Copyright (c) 2024 Maho (https://mahocommerce.com) | ||
# @copyright Copyright (c) (2024-)2024 Maho (https://mahocommerce.com) | ||
if ! grep -E -q "Copyright \(c\) (\(2024-\))?${CURRENT_YEAR} Maho \(https://mahocommerce\.com\)" "$file"; then | ||
echo "❌ Copyright notice missing in: $file" | ||
ERROR=1 | ||
fi | ||
done | ||
# Exit with error if any file is missing copyright | ||
if [ $ERROR -eq 1 ]; then | ||
echo "❌ Error: Some files are missing the required copyright notice" | ||
exit 1 | ||
fi | ||
echo "✅ Success: All modified files contain the required copyright notice" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.