Files
hassio-addons/.github/workflows/onpush_superlinter.yml
2025-06-15 12:51:23 +02:00

67 lines
2.1 KiB
YAML

name: Lint On Change
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
run-lint:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fix non-printable Unicode spaces in changed text files
run: |
echo "Finding changed files..."
CHANGED_FILES=$(git diff --name-only origin/master...HEAD)
# Unicode blanks regex (covers all mentioned codepoints)
UNICODE_SPACES_REGEX=$'[\u00A0\u2002\u2003\u2007\u2008\u2009\u202F\u205F\u3000\u200B]'
for file in $CHANGED_FILES; do
if [ -f "$file" ]; then
MIME_TYPE=$(file --mime-type -b "$file")
if [[ "$MIME_TYPE" == text/* ]]; then
echo "Fixing: $file"
perl -CSD -pe "s/$UNICODE_SPACES_REGEX/ /g" "$file" > "$file.tmp" && mv "$file.tmp" "$file"
else
echo "Skipping non-text file: $file ($MIME_TYPE)"
fi
fi
done
- name: Run Super Linter
uses: super-linter/super-linter/slim@main
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VALIDATE_ALL_CODEBASE: false
VALIDATE_CHECKOV: false
VALIDATE_PYTHON_PYLINT: false
VALIDATE_JSCPD: false
VALIDATE_NATURAL_LANGUAGE: false
FILTER_REGEX_EXCLUDE: .github/workflows/.*
FIX_ENV: true
FIX_HTML_PRETTIER: true
FIX_SHELL_SHFMT: true
FIX_YAML_PRETTIER: true
FIX_JSON: true
#FIX_JSON_PRETTIER: true
FIX_MARKDOWN: true
#FIX_MARKDOWN_PRETTIER: true
FIX_PYTHON_BLACK: true
FIX_PYTHON_ISORT: true
FIX_PYTHON_RUFF: true
- name: Commit and push linting fixes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: fix linting issues"
commit_user_name: super-linter
commit_user_email: super-linter@super-linter.dev