From f74b4bb54fda1eca46165e22e59b027f757d4071 Mon Sep 17 00:00:00 2001 From: Florian Pfaff Date: Thu, 7 May 2026 13:59:57 +0200 Subject: [PATCH] Improve MegaLinter configuration --- .github/workflows/mega-linter.yml | 93 +++++++++++++++++++++++++++++++ .mega-linter.yml | 15 +++++ 2 files changed, 108 insertions(+) create mode 100644 .github/workflows/mega-linter.yml create mode 100644 .mega-linter.yml diff --git a/.github/workflows/mega-linter.yml b/.github/workflows/mega-linter.yml new file mode 100644 index 0000000..b9c7954 --- /dev/null +++ b/.github/workflows/mega-linter.yml @@ -0,0 +1,93 @@ +--- +# MegaLinter GitHub Action configuration file +# More info at https://megalinter.io +name: MegaLinter + +permissions: + checks: write + pull-requests: write + contents: write + +on: # yamllint disable-line rule:truthy + push: + branches: + - main + pull_request: + branches: + - main + workflow_dispatch: + +env: + APPLY_FIXES: all + APPLY_FIXES_EVENT: push + APPLY_FIXES_MODE: pull_request + +concurrency: + group: ${{ github.ref }}-${{ github.workflow }} + cancel-in-progress: true + +jobs: + build: + name: MegaLinter + runs-on: ubuntu-latest + permissions: + contents: write + issues: write + pull-requests: write + steps: + - name: Checkout Code + uses: actions/checkout@v6 + with: + ref: ${{ github.head_ref }} + fetch-depth: 0 + + - name: MegaLinter + id: ml + uses: oxsecurity/megalinter/flavors/python@v9.4.0 + env: + VALIDATE_ALL_CODEBASE: true + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Archive production artifacts + if: always() + uses: actions/upload-artifact@v7 + with: + name: MegaLinter reports + path: | + megalinter-reports + mega-linter.log + + - name: Remove generated MegaLinter reports before PR creation + if: always() + run: sudo rm -rf megalinter-reports mega-linter.log + + - name: Create Pull Request with applied fixes + id: cpr + if: github.ref == 'refs/heads/main' && steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + uses: peter-evans/create-pull-request@v8 + with: + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} + commit-message: "[MegaLinter] Apply linters automatic fixes" + title: "[MegaLinter] Apply linters automatic fixes" + branch: megalinter-fixes + labels: bot + base: main + + - name: Create PR output + if: github.ref == 'refs/heads/main' && steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'pull_request' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + run: | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" + + - name: Prepare commit + if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + run: sudo chown -Rc "$UID" .git/ + + - name: Commit and push applied linter fixes + if: steps.ml.outputs.has_updated_sources == 1 && (env.APPLY_FIXES_EVENT == 'all' || env.APPLY_FIXES_EVENT == github.event_name) && env.APPLY_FIXES_MODE == 'commit' && github.ref != 'refs/heads/main' && (github.event_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix') + uses: stefanzweifel/git-auto-commit-action@v7 + with: + branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} + commit_message: "[MegaLinter] Apply linters fixes" + commit_user_name: megalinter-bot + commit_user_email: megalinter-bot@florianpfaff.de diff --git a/.mega-linter.yml b/.mega-linter.yml new file mode 100644 index 0000000..8345878 --- /dev/null +++ b/.mega-linter.yml @@ -0,0 +1,15 @@ +--- +ENABLE_LINTERS: + - ACTION_ACTIONLINT + - COPYPASTE_JSCPD + - MARKDOWN_MARKDOWNLINT + - PYTHON_RUFF + - REPOSITORY_GIT_DIFF + - YAML_PRETTIER + - YAML_YAMLLINT + - YAML_V8R + +VALIDATE_ALL_CODEBASE: true +PRINT_ALPACA: false +SHOW_ELAPSED_TIME: true +FLAVOR_SUGGESTIONS: false