Skip to content

Commit 17bf49c

Browse files
authored
Update MegaLinter workflow with new permissions and steps
Elevate permissions for PR comments and automated fixes. Add steps for committing automated fixes and uploading reports.
1 parent 44f6a41 commit 17bf49c

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

.github/workflows/mega-linter.yml

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,50 @@ on:
77
pull_request:
88
branches: [main, master]
99

10+
# Elevating permissions to allow PR comments and automated fixing commits
1011
permissions:
11-
contents: read
12+
contents: write
1213
statuses: write
14+
pull_requests: write
1315

1416
jobs:
1517
megalinter:
1618
name: MegaLinter
1719
runs-on: ubuntu-latest
1820
steps:
21+
# Git Checkout
1922
- name: Checkout Code
2023
uses: actions/checkout@v4
2124
with:
2225
token: ${{ secrets.GITHUB_TOKEN }}
2326
fetch-depth: 0
2427

28+
# MegaLinter Execution
2529
- name: Run MegaLinter
2630
uses: oxsecurity/megalinter@v7
2731
env:
2832
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2933
VALIDATE_ALL_CODEBASE: false
34+
# Enables individual linter engines to fix errors locally in the runner
35+
APPLY_FIXES: all
36+
APPLY_FIXES_EVENT: all
37+
38+
# Push automated fixes back to your repository branch
39+
- name: Commit Automated Fixes
40+
if: success() || failure()
41+
uses: stefanzweifel/git-auto-commit-action@v5
42+
with:
43+
branch: ${{ github.head_ref || github.ref_name }}
44+
commit_message: "chore: automated code formatting fixes by MegaLinter"
45+
commit_user_name: megalinter-bot
46+
commit_user_email: megalinter-bot@ox.security
47+
48+
# Upload the visual HTML dashboards and asset logs
49+
- name: Upload MegaLinter Reports
50+
if: success() || failure()
51+
uses: actions/upload-artifact@v4
52+
with:
53+
name: MegaLinter-reports
54+
path: |
55+
megalinter-reports
56+
mega-linter.log

0 commit comments

Comments
 (0)