|
52 | 52 | with: |
53 | 53 | project-token: ${{ secrets.CODACY_PROJECT_TOKEN }} |
54 | 54 | coverage-reports: ${{ env.lcov_files }} |
| 55 | + |
| 56 | + quality: |
| 57 | + name: MegaLinter |
| 58 | + runs-on: ubuntu-latest |
| 59 | + steps: |
| 60 | + # Git Checkout |
| 61 | + - name: Checkout Code |
| 62 | + uses: actions/checkout@v3 |
| 63 | + with: |
| 64 | + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
| 65 | + fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances |
| 66 | + |
| 67 | + # MegaLinter |
| 68 | + - name: MegaLinter |
| 69 | + id: ml |
| 70 | + # You can override MegaLinter flavor used to have faster performances |
| 71 | + # More info at https://megalinter.io/flavors/ |
| 72 | + uses: oxsecurity/megalinter@v6 |
| 73 | + env: |
| 74 | + # All available variables are described in documentation |
| 75 | + # https://megalinter.io/configuration/ |
| 76 | + VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} # Validates all source when push on main, else just the git diff with main. Override with true if you always want to lint all sources |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + # ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY |
| 79 | + # DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks |
| 80 | + |
| 81 | + # Upload MegaLinter artifacts |
| 82 | + - name: Archive production artifacts |
| 83 | + if: ${{ success() }} || ${{ failure() }} |
| 84 | + uses: actions/upload-artifact@v3 |
| 85 | + with: |
| 86 | + name: MegaLinter reports |
| 87 | + path: | |
| 88 | + megalinter-reports |
| 89 | + mega-linter.log |
| 90 | +
|
| 91 | + # Create pull request if applicable (for now works only on PR from same repository, not from forks) |
| 92 | + - name: Create Pull Request with applied fixes |
| 93 | + id: cpr |
| 94 | + 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) |
| 95 | + uses: peter-evans/create-pull-request@v4 |
| 96 | + with: |
| 97 | + token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
| 98 | + commit-message: "[MegaLinter] Apply linters automatic fixes" |
| 99 | + title: "[MegaLinter] Apply linters automatic fixes" |
| 100 | + labels: bot |
| 101 | + - name: Create PR output |
| 102 | + 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) |
| 103 | + run: | |
| 104 | + echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" |
| 105 | + echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
| 106 | +
|
| 107 | + # Push new commit if applicable (for now works only on PR from same repository, not from forks) |
| 108 | + - name: Prepare commit |
| 109 | + 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) |
| 110 | + run: sudo chown -Rc $UID .git/ |
| 111 | + - name: Commit and push applied linter fixes |
| 112 | + 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) |
| 113 | + uses: stefanzweifel/git-auto-commit-action@v4 |
| 114 | + with: |
| 115 | + branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} |
| 116 | + commit_message: "[MegaLinter] Apply linters fixes" |
0 commit comments