|
3 | 3 | --- |
4 | 4 | name: MegaLinter |
5 | 5 |
|
6 | | - # Trigger mega-linter at every push. Action will also be visible from Pull Requests to main |
| 6 | + # Trigger mega-linter at every pull request. |
7 | 7 | on: |
8 | 8 | # Comment this line to trigger action only on pull-requests |
9 | 9 | # (not recommended if you don't pay for GH Actions) |
10 | 10 | # push: |
11 | 11 |
|
12 | 12 | pull_request: |
13 | | - branches: |
| 13 | + # branches: |
14 | 14 | # - main |
15 | | - - testing |
| 15 | + # - testing |
16 | 16 | # - dev |
17 | 17 | # - experimental |
18 | 18 |
|
|
44 | 44 | # Give the default GITHUB_TOKEN write permission to commit and push, comment |
45 | 45 | # issues & post new PR; remove the ones you do not need |
46 | 46 | permissions: |
47 | | - contents: write |
48 | | - issues: write |
49 | | - pull-requests: write |
| 47 | + contents: read |
| 48 | + issues: read |
| 49 | + pull-requests: read |
50 | 50 |
|
51 | 51 | steps: |
52 | 52 |
|
|
58 | 58 |
|
59 | 59 | # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to |
60 | 60 | # improve performance |
61 | | - fetch-depth: 0 |
| 61 | + # fetch-depth: 0 |
62 | 62 |
|
63 | 63 | # MegaLinter |
64 | 64 | - name: MegaLinter |
65 | 65 |
|
66 | 66 | # You can override MegaLinter flavor used to have faster performances |
67 | 67 | # More info at https://megalinter.io/flavors/ |
68 | 68 | # The dotnet flavor includes PowerShell, MD, YAML, JSON, spelling, and more. |
69 | | - uses: oxsecurity/megalinter/flavors/dotnet@v7.7.0 |
| 69 | + uses: oxsecurity/megalinter/flavors/dotnet@v8.3.0 |
70 | 70 |
|
71 | 71 | id: ml |
72 | 72 |
|
|
78 | 78 | # main. Override with true if you always want to lint all sources |
79 | 79 | # |
80 | 80 | # To validate the entire codebase, set to: |
81 | | - # VALIDATE_ALL_CODEBASE: true |
| 81 | + VALIDATE_ALL_CODEBASE: true |
82 | 82 | # |
83 | 83 | # To validate only diff with main, set to: |
84 | 84 | # VALIDATE_ALL_CODEBASE: >- |
85 | 85 | # ${{ |
86 | 86 | # github.event_name == 'push' && |
87 | 87 | # contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) |
88 | 88 | # }} |
89 | | - VALIDATE_ALL_CODEBASE: >- |
90 | | - ${{ |
91 | | - github.event_name == 'push' && |
92 | | - contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) |
93 | | - }} |
| 89 | + # VALIDATE_ALL_CODEBASE: >- |
| 90 | + # ${{ |
| 91 | + # github.event_name == 'push' && |
| 92 | + # contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref) |
| 93 | + # }} |
94 | 94 |
|
95 | 95 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
96 | 96 |
|
|
113 | 113 | path: | |
114 | 114 | megalinter-reports |
115 | 115 | mega-linter.log |
116 | | -
|
117 | | - # Set APPLY_FIXES_IF var for use in future steps |
118 | | - - name: Set APPLY_FIXES_IF var |
119 | | - run: | |
120 | | - printf 'APPLY_FIXES_IF=%s\n' "${{ |
121 | | - steps.ml.outputs.has_updated_sources == 1 && |
122 | | - ( |
123 | | - env.APPLY_FIXES_EVENT == 'all' || |
124 | | - env.APPLY_FIXES_EVENT == github.event_name |
125 | | - ) && |
126 | | - ( |
127 | | - github.event_name == 'push' || |
128 | | - github.event.pull_request.head.repo.full_name == github.repository |
129 | | - ) |
130 | | - }}" >> "${GITHUB_ENV}" |
131 | | -
|
132 | | - # Set APPLY_FIXES_IF_* vars for use in future steps |
133 | | - - name: Set APPLY_FIXES_IF_* vars |
134 | | - run: | |
135 | | - printf 'APPLY_FIXES_IF_PR=%s\n' "${{ |
136 | | - env.APPLY_FIXES_IF == 'true' && |
137 | | - env.APPLY_FIXES_MODE == 'pull_request' |
138 | | - }}" >> "${GITHUB_ENV}" |
139 | | - printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{ |
140 | | - env.APPLY_FIXES_IF == 'true' && |
141 | | - env.APPLY_FIXES_MODE == 'commit' && |
142 | | - (!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref)) |
143 | | - }}" >> "${GITHUB_ENV}" |
144 | | -
|
145 | | - # Create pull request if applicable |
146 | | - # (for now works only on PR from same repository, not from forks) |
147 | | - - name: Create Pull Request with applied fixes |
148 | | - uses: peter-evans/create-pull-request@v5 |
149 | | - id: cpr |
150 | | - if: env.APPLY_FIXES_IF_PR == 'true' |
151 | | - with: |
152 | | - token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }} |
153 | | - commit-message: "[MegaLinter] Apply linters automatic fixes" |
154 | | - title: "[MegaLinter] Apply linters automatic fixes" |
155 | | - labels: bot |
156 | | - |
157 | | - - name: Create PR output |
158 | | - if: env.APPLY_FIXES_IF_PR == 'true' |
159 | | - run: | |
160 | | - echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}" |
161 | | - echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}" |
162 | | -
|
163 | | - # Push new commit if applicable |
164 | | - # (for now works only on PR from same repository, not from forks) |
165 | | - - name: Prepare commit |
166 | | - if: env.APPLY_FIXES_IF_COMMIT == 'true' |
167 | | - run: sudo chown -Rc $UID .git/ |
168 | | - |
169 | | - - name: Commit and push applied linter fixes |
170 | | - uses: stefanzweifel/git-auto-commit-action@v5 |
171 | | - if: env.APPLY_FIXES_IF_COMMIT == 'true' |
172 | | - with: |
173 | | - branch: >- |
174 | | - ${{ |
175 | | - github.event.pull_request.head.ref || |
176 | | - github.head_ref || |
177 | | - github.ref |
178 | | - }} |
179 | | - commit_message: "[MegaLinter] Apply linters fixes" |
180 | | - commit_user_name: megalinter-bot |
181 | | - commit_user_email: megalinter@dotdot.horse |
0 commit comments