mirror of
https://github.com/alexbelgium/hassio-addons.git
synced 2026-01-13 03:11:02 +01:00
57 lines
1.6 KiB
YAML
57 lines
1.6 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-breaking spaces in changed text files
|
|
run: |
|
|
echo "Finding changed files..."
|
|
CHANGED_FILES=$(git diff --name-only origin/master...HEAD)
|
|
|
|
echo "Filtering text files..."
|
|
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"
|
|
sed -i 's/\xC2\xA0/ /g' "$file"
|
|
else
|
|
echo "Skipping non-text file: $file ($MIME_TYPE)"
|
|
fi
|
|
fi
|
|
done
|
|
|
|
if [[ -n "$(git status --porcelain)" ]]; then
|
|
git config user.name "github-actions"
|
|
git config user.email "github-actions@github.com"
|
|
git add .
|
|
git commit -m "fix: replace non-breaking spaces in changed text files"
|
|
git push
|
|
else
|
|
echo "No changes to commit."
|
|
fi
|
|
|
|
- name: Run Super Linter
|
|
uses: super-linter/super-linter/slim@main
|
|
env:
|
|
VALIDATE_CHECKOV: false
|
|
VALIDATE_PYTHON_PYLINT: false
|
|
VALIDATE_JSCPD: false
|
|
VALIDATE_NATURAL_LANGUAGE: false
|
|
FILTER_REGEX_EXCLUDE: .github/workflows/.*
|
|
VALIDATE_ALL_CODEBASE: false
|
|
DEFAULT_BRANCH: master
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|