Skip to content

Commit

Permalink
Update mega-linter.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
domalab authored Feb 21, 2025
1 parent 34cde8b commit aa1b7ea
Showing 1 changed file with 7 additions and 20 deletions.
27 changes: 7 additions & 20 deletions .github/workflows/mega-linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# More info at https://megalinter.io
name: MegaLinter
on:
# Trigger mega-linter at every push and pull request to main or master branches
push:
branches: [main, master]
pull_request:
branches: [main, master]

env: # Environment variables for MegaLinter
# Apply linter fixes configuration
APPLY_FIXES: "PYTHON_BLACK,PYTHON_ISORT" # Apply fixes only for Black (formatter) and Isort (import sorter)
env:
APPLY_FIXES: "PYTHON_BLACK,PYTHON_ISORT" # Apply fixes only for Black and Isort
APPLY_FIXES_EVENT: pull_request # Apply fixes only during pull requests
APPLY_FIXES_MODE: commit # Commit fixes directly to the branch
VALIDATE_ALL_CODEBASE: true # Validate all files in the repository
LOG_LEVEL: DEBUG # Enable verbose logging for debugging

concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
Expand All @@ -23,7 +23,6 @@ jobs:
name: MegaLinter
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR
contents: write
issues: write
pull-requests: write
Expand All @@ -41,11 +40,9 @@ jobs:
id: ml
uses: oxsecurity/megalinter@v8
env:
# Focus only on Python and JSON files
FLAVOR: python # Use the Python flavor to optimize performance
ENABLE_LINTERS: "PYTHON_FLAKE8,PYTHON_PYLINT,PYTHON_BLACK,PYTHON_ISORT,JSON_JSONLINT" # Enable specific linters for Python and JSON
DISABLE_LINTERS: "COPYPASTE,SPELL" # Disable unnecessary linters like copy-paste detection and spell checks
VALIDATE_ALL_CODEBASE: false # Validate only changed files in pull requests or commits
DISABLE_LINTERS: "COPYPASTE,SPELL" # Disable unnecessary linters
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# Upload MegaLinter artifacts
Expand All @@ -58,7 +55,7 @@ jobs:
megalinter-reports
mega-linter.log
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
# Create pull request if applicable
- name: Create Pull Request with applied fixes
id: cpr
if: 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')
Expand All @@ -69,17 +66,7 @@ jobs:
title: "[MegaLinter] Apply linters automatic fixes"
labels: bot

- name: Create PR output
if: 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 }}"
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
- 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/

# Commit and push applied linter fixes
- 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@v4
Expand Down

0 comments on commit aa1b7ea

Please sign in to comment.