|
1 | | ---- |
2 | 1 | # MegaLinter GitHub Action configuration file |
3 | | -# More info at https://megalinter.github.io |
| 2 | +# More info at https://megalinter.io |
| 3 | +--- |
4 | 4 | name: MegaLinter |
5 | 5 |
|
| 6 | +# Trigger mega-linter at every push. Action will also be visible from |
| 7 | +# Pull Requests to main |
6 | 8 | on: |
7 | | - # Trigger mega-linter at every push. Action will also be visible from Pull Requests to master |
8 | | - push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions) |
| 9 | + # Comment this line to trigger action only on pull-requests |
| 10 | + # (not recommended if you don't pay for GH Actions) |
| 11 | + push: |
| 12 | + |
9 | 13 | pull_request: |
10 | | - branches: [master, main] |
| 14 | + branches: |
| 15 | + - main |
| 16 | + - master |
11 | 17 |
|
12 | | -env: # Comment env block if you do not want to apply fixes |
| 18 | +# Comment env block if you do not want to apply fixes |
| 19 | +env: |
13 | 20 | # Apply linter fixes configuration |
14 | | - APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool) |
15 | | - APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, push, all) |
16 | | - APPLY_FIXES_MODE: commit # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) or posted in a PR (pull_request) |
| 21 | + # |
| 22 | + # When active, APPLY_FIXES must also be defined as environment variable |
| 23 | + # (in github/workflows/mega-linter.yml or other CI tool) |
| 24 | + APPLY_FIXES: all |
| 25 | + |
| 26 | + # Decide which event triggers application of fixes in a commit or a PR |
| 27 | + # (pull_request, push, all) |
| 28 | + APPLY_FIXES_EVENT: pull_request |
| 29 | + |
| 30 | + # If APPLY_FIXES is used, defines if the fixes are directly committed (commit) |
| 31 | + # or posted in a PR (pull_request) |
| 32 | + APPLY_FIXES_MODE: commit |
17 | 33 |
|
18 | 34 | concurrency: |
19 | 35 | group: ${{ github.ref }}-${{ github.workflow }} |
20 | 36 | cancel-in-progress: true |
21 | 37 |
|
22 | 38 | jobs: |
23 | | - build: |
| 39 | + megalinter: |
24 | 40 | name: MegaLinter |
25 | 41 | runs-on: ubuntu-latest |
| 42 | + |
| 43 | + # Give the default GITHUB_TOKEN write permission to commit and push, comment |
| 44 | + # issues, and post new Pull Requests; remove the ones you do not need |
| 45 | + permissions: |
| 46 | + contents: write |
| 47 | + issues: write |
| 48 | + pull-requests: write |
| 49 | + |
26 | 50 | steps: |
27 | 51 | # Git Checkout |
28 | 52 | - name: Checkout Code |
29 | | - uses: actions/checkout@v2 |
| 53 | + uses: actions/checkout@v4 |
30 | 54 | with: |
31 | 55 | token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
| 56 | + |
| 57 | + # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to |
| 58 | + # improve performance |
32 | 59 | fetch-depth: 0 |
33 | 60 |
|
34 | 61 | # MegaLinter |
35 | 62 | - name: MegaLinter |
36 | | - id: ml |
| 63 | + |
37 | 64 | # You can override MegaLinter flavor used to have faster performances |
38 | | - # More info at https://megalinter.github.io/flavors/ |
39 | | - uses: megalinter/megalinter@v5 |
| 65 | + # More info at https://megalinter.io/latest/flavors/ |
| 66 | + uses: oxsecurity/megalinter@v8 |
| 67 | + |
| 68 | + id: ml |
| 69 | + |
| 70 | + # All available variables are described in documentation |
| 71 | + # https://megalinter.io/latest/config-file/ |
40 | 72 | env: |
41 | | - # All available variables are described in documentation |
42 | | - # https://megalinter.github.io/configuration/ |
43 | | - VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 73 | + # Validates all source when push on main, else just the git diff with |
| 74 | + # main. Override with true if you always want to lint all sources |
| 75 | + # |
| 76 | + # To validate the entire codebase, set to: |
| 77 | + # VALIDATE_ALL_CODEBASE: true |
| 78 | + # |
| 79 | + # To validate only diff with main, set to: |
| 80 | + # VALIDATE_ALL_CODEBASE: >- |
| 81 | + # ${{ |
| 82 | + # github.event_name == 'push' && |
| 83 | + # github.ref == 'refs/heads/main' |
| 84 | + # }} |
| 85 | + VALIDATE_ALL_CODEBASE: >- |
| 86 | + ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} |
| 87 | +
|
44 | 88 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
45 | | - # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY |
| 89 | + |
| 90 | + # Uncomment to use ApiReporter (Grafana) |
| 91 | + # API_REPORTER: true |
| 92 | + # API_REPORTER_URL: ${{ secrets.API_REPORTER_URL }} |
| 93 | + # API_REPORTER_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_BASIC_AUTH_USERNAME }} |
| 94 | + # API_REPORTER_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_BASIC_AUTH_PASSWORD }} |
| 95 | + # API_REPORTER_METRICS_URL: ${{ secrets.API_REPORTER_METRICS_URL }} |
| 96 | + # API_REPORTER_METRICS_BASIC_AUTH_USERNAME: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_USERNAME }} |
| 97 | + # API_REPORTER_METRICS_BASIC_AUTH_PASSWORD: ${{ secrets.API_REPORTER_METRICS_BASIC_AUTH_PASSWORD }} |
| 98 | + # API_REPORTER_DEBUG: false |
| 99 | + |
| 100 | + # ADD YOUR CUSTOM ENV VARIABLES HERE TO OVERRIDE VALUES OF |
| 101 | + # .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY |
46 | 102 |
|
47 | 103 | # Upload MegaLinter artifacts |
48 | 104 | - name: Archive production artifacts |
49 | | - if: ${{ success() }} || ${{ failure() }} |
50 | | - uses: actions/upload-artifact@v2 |
| 105 | + uses: actions/upload-artifact@v4 |
| 106 | + if: success() || failure() |
51 | 107 | with: |
52 | 108 | name: MegaLinter reports |
| 109 | + include-hidden-files: "true" |
53 | 110 | path: | |
54 | | - report |
| 111 | + megalinter-reports |
55 | 112 | mega-linter.log |
56 | 113 |
|
57 | | - # Create pull request if applicable (for now works only on PR from same repository, not from forks) |
| 114 | + # Create pull request if applicable |
| 115 | + # (for now works only on PR from same repository, not from forks) |
58 | 116 | - name: Create Pull Request with applied fixes |
| 117 | + uses: peter-evans/create-pull-request@v6 |
59 | 118 | id: cpr |
60 | | - 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') |
61 | | - uses: peter-evans/create-pull-request@v3 |
| 119 | + if: >- |
| 120 | + steps.ml.outputs.has_updated_sources == 1 && |
| 121 | + ( |
| 122 | + env.APPLY_FIXES_EVENT == 'all' || |
| 123 | + env.APPLY_FIXES_EVENT == github.event_name |
| 124 | + ) && |
| 125 | + env.APPLY_FIXES_MODE == 'pull_request' && |
| 126 | + ( |
| 127 | + github.event_name == 'push' || |
| 128 | + github.event.pull_request.head.repo.full_name == github.repository |
| 129 | + ) && |
| 130 | + !contains(github.event.head_commit.message, 'skip fix') |
62 | 131 | with: |
63 | 132 | token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
64 | 133 | commit-message: "[MegaLinter] Apply linters automatic fixes" |
65 | 134 | title: "[MegaLinter] Apply linters automatic fixes" |
66 | 135 | labels: bot |
| 136 | + |
67 | 137 | - name: Create PR output |
68 | | - 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') |
| 138 | + if: >- |
| 139 | + steps.ml.outputs.has_updated_sources == 1 && |
| 140 | + ( |
| 141 | + env.APPLY_FIXES_EVENT == 'all' || |
| 142 | + env.APPLY_FIXES_EVENT == github.event_name |
| 143 | + ) && |
| 144 | + env.APPLY_FIXES_MODE == 'pull_request' && |
| 145 | + ( |
| 146 | + github.event_name == 'push' || |
| 147 | + github.event.pull_request.head.repo.full_name == github.repository |
| 148 | + ) && |
| 149 | + !contains(github.event.head_commit.message, 'skip fix') |
69 | 150 | run: | |
70 | | - echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}" |
71 | | - echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}" |
| 151 | + echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}" |
| 152 | + echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}" |
72 | 153 |
|
73 | | - # Push new commit if applicable (for now works only on PR from same repository, not from forks) |
| 154 | + # Push new commit if applicable |
| 155 | + # (for now works only on PR from same repository, not from forks) |
74 | 156 | - name: Prepare commit |
75 | | - 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') |
| 157 | + if: >- |
| 158 | + steps.ml.outputs.has_updated_sources == 1 && |
| 159 | + ( |
| 160 | + env.APPLY_FIXES_EVENT == 'all' || |
| 161 | + env.APPLY_FIXES_EVENT == github.event_name |
| 162 | + ) && |
| 163 | + env.APPLY_FIXES_MODE == 'commit' && |
| 164 | + github.ref != 'refs/heads/main' && |
| 165 | + ( |
| 166 | + github.event_name == 'push' || |
| 167 | + github.event.pull_request.head.repo.full_name == github.repository |
| 168 | + ) && |
| 169 | + !contains(github.event.head_commit.message, 'skip fix') |
76 | 170 | run: sudo chown -Rc $UID .git/ |
| 171 | + |
77 | 172 | - name: Commit and push applied linter fixes |
78 | | - 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') |
79 | | - uses: stefanzweifel/git-auto-commit-action@v4 |
| 173 | + uses: stefanzweifel/git-auto-commit-action@v5 |
| 174 | + if: >- |
| 175 | + steps.ml.outputs.has_updated_sources == 1 && |
| 176 | + ( |
| 177 | + env.APPLY_FIXES_EVENT == 'all' || |
| 178 | + env.APPLY_FIXES_EVENT == github.event_name |
| 179 | + ) && |
| 180 | + env.APPLY_FIXES_MODE == 'commit' && |
| 181 | + github.ref != 'refs/heads/main' && |
| 182 | + ( |
| 183 | + github.event_name == 'push' || |
| 184 | + github.event.pull_request.head.repo.full_name == github.repository |
| 185 | + ) && |
| 186 | + !contains(github.event.head_commit.message, 'skip fix') |
80 | 187 | with: |
81 | | - branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }} |
| 188 | + branch: >- |
| 189 | + ${{ |
| 190 | + github.event.pull_request.head.ref || |
| 191 | + github.head_ref || |
| 192 | + github.ref |
| 193 | + }} |
82 | 194 | commit_message: "[MegaLinter] Apply linters fixes" |
| 195 | + commit_user_name: megalinter-bot |
| 196 | + commit_user_email: 129584137+megalinter-bot@users.noreply.github.com |
0 commit comments