Fixed admin:user:create failing when admin role has different name …
#4922
This file contains hidden or 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
| name: Copyright Check | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| check-copyright: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v6 | |
| - 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@v47 | |
| - 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 | |
| # List of files to ignore | |
| ignore=" | |
| .phpcs.xml | |
| .php-cs-fixer.php | |
| .rector.php | |
| .phpstorm.meta.php/blocks.meta.php | |
| .phpstorm.meta.php/helpers.meta.php | |
| .phpstorm.meta.php/models.meta.php | |
| .phpstorm.meta.php/registry.meta.php | |
| .phpstorm.meta.php/resource_models.meta.php | |
| " | |
| # Build regex pattern with valid years | |
| NEXT_YEAR=$((CURRENT_YEAR + 1)) | |
| MIN_YEAR=2024 | |
| # Build list of valid start years (2024|2025|...|CURRENT_YEAR) | |
| VALID_START_YEARS="" | |
| for year in $(seq $MIN_YEAR $CURRENT_YEAR); do | |
| if [ -n "$VALID_START_YEARS" ]; then | |
| VALID_START_YEARS="${VALID_START_YEARS}|" | |
| fi | |
| VALID_START_YEARS="${VALID_START_YEARS}${year}" | |
| done | |
| # Build pattern that matches: | |
| # - Year ranges: (2024|2025|...)-(CURRENT_YEAR|NEXT_YEAR) | |
| # - Single year: CURRENT_YEAR|NEXT_YEAR | |
| PATTERN="Copyright \(c\) ((${VALID_START_YEARS})-(${CURRENT_YEAR}|${NEXT_YEAR})|(${CURRENT_YEAR}|${NEXT_YEAR})) Maho \(https://mahocommerce\.com\)" | |
| # 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,,}" =~ ^(js|php|phtml)$ ]]; then | |
| continue | |
| fi | |
| # Check ignored files | |
| if $( echo $ignore | grep -w -q $file ); then | |
| continue; | |
| fi | |
| # Check if file contains valid copyright pattern | |
| if ! grep -E -q "$PATTERN" "$file"; then | |
| echo "❌ Invalid or missing copyright notice in: $file" | |
| echo " Expected: Copyright (c) [2024-${CURRENT_YEAR}]-(${CURRENT_YEAR}|${NEXT_YEAR}) or (${CURRENT_YEAR}|${NEXT_YEAR}) Maho (https://mahocommerce.com)" | |
| 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" |