Skip to content

Commit 3454b56

Browse files
authored
Merge pull request #1 from joe-sharp/add_mega_linter
Add Mega Linter with remote rules
2 parents 0ef421e + 2162bc8 commit 3454b56

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed

.github/workflows/mega-linter.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
---
2+
# Mega-Linter GitHub Action configuration file
3+
# More info at https://nvuillam.github.io/mega-linter
4+
name: Mega-Linter
5+
6+
on:
7+
# Trigger mega-linter at every push. Action will also be visible from Pull Requests to main
8+
push: # Comment this line to trigger action only on pull-requests (not recommended if you don't pay for GH Actions)
9+
pull_request:
10+
branches: [main]
11+
12+
# env: #Uncomment to activate variables below
13+
# Apply linter fixes configuration
14+
# APPLY_FIXES: all # Uncomment to apply fixes provided by linters. You can also specify the list of fixing linters
15+
# APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request (default), 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)
17+
18+
jobs:
19+
# Cancel duplicate jobs: https://github.com/fkirc/skip-duplicate-actions#option-3-cancellation-only
20+
cancel_duplicates:
21+
name: Cancel duplicate jobs
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: fkirc/skip-duplicate-actions@master
25+
with:
26+
github_token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
27+
28+
build:
29+
name: Mega-Linter
30+
runs-on: ubuntu-latest
31+
steps:
32+
# Git Checkout
33+
- name: Checkout Code
34+
uses: actions/checkout@v2
35+
with:
36+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
37+
fetch-depth: 0
38+
submodules: true
39+
40+
# Mega-Linter
41+
- name: Mega-Linter
42+
id: ml
43+
uses: nvuillam/mega-linter@v4
44+
env:
45+
# All available variables are described in documentation
46+
# https://nvuillam.github.io/mega-linter/configuration/
47+
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
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
DEFAULT_BRANCH: main
50+
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
51+
# DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks
52+
LINTER_RULES_PATH: https://raw.githubusercontent.com/joe-sharp/linter-configs/main
53+
54+
# Upload Mega-Linter artifacts
55+
- name: Archive production artifacts
56+
if: ${{ success() }} || ${{ failure() }}
57+
uses: actions/upload-artifact@v2
58+
with:
59+
name: Mega-Linter reports
60+
path: |
61+
report
62+
mega-linter.log
63+
64+
# Create pull request if applicable (for now works only on PR from same repository, not from forks)
65+
- name: Create Pull Request with applied fixes
66+
id: cpr
67+
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.pull_request.head.repo.full_name == github.repository
68+
uses: peter-evans/create-pull-request@v3
69+
with:
70+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
71+
commit-message: "[Mega-Linter] Apply linters automatic fixes"
72+
title: "[Mega-Linter] Apply linters automatic fixes"
73+
labels: bot
74+
- name: Create PR output
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 == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
76+
run: |
77+
echo "Pull Request Number - ${{ steps.cpr.outputs.pull-request-number }}"
78+
echo "Pull Request URL - ${{ steps.cpr.outputs.pull-request-url }}"
79+
80+
# Push new commit if applicable (for now works only on PR from same repository, not from forks)
81+
- name: Prepare commit
82+
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.pull_request.head.repo.full_name == github.repository
83+
run: sudo chown -Rc $UID .git/
84+
- name: Commit and push applied linter fixes
85+
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.pull_request.head.repo.full_name == github.repository
86+
uses: stefanzweifel/git-auto-commit-action@v4
87+
with:
88+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
89+
commit_message: "[Mega-Linter] Apply linters fixes"

0 commit comments

Comments
 (0)