Skip to content

Commit 605bf64

Browse files
committed
Use Actions-based linter
1 parent f51e678 commit 605bf64

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

.github/workflows/lint.yml

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Lint
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
7+
env:
8+
APPLY_FIXES: all
9+
APPLY_FIXES_EVENT: pull_request
10+
APPLY_FIXES_MODE: commit
11+
12+
concurrency:
13+
group: ${{ github.ref }}-${{ github.workflow }}
14+
cancel-in-progress: true
15+
16+
jobs:
17+
lint:
18+
name: Lint
19+
runs-on: ubuntu-22.04
20+
steps:
21+
- name: Checkout repo
22+
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b
23+
24+
- name: Lint
25+
id: ml
26+
uses: oxsecurity/megalinter@f8d535e8f1b5be62df8ea5c9c8548035fc298788
27+
env:
28+
VALIDATE_ALL_CODEBASE: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Archive production artifacts
32+
if: ${{ success() }} || ${{ failure() }}
33+
uses: actions/upload-artifact@6673cd052c4cd6fcf4b4e6e60ea986c889389535
34+
with:
35+
name: Lint Report
36+
path: |
37+
megalinter-reports
38+
mega-linter.log
39+
40+
- name: Create pull pequest with applied fixes
41+
id: cpr
42+
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')
43+
uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04
44+
with:
45+
token: ${{ secrets.GITHUB_TOKEN }}
46+
commit-message: "Apply lint fixes"
47+
title: "Apply lint fixes"
48+
labels: bot
49+
- name: Create PR output
50+
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')
51+
run: |
52+
echo "PR: ${{ steps.cpr.outputs.pull-request-number }}"
53+
echo "PR URL: ${{ steps.cpr.outputs.pull-request-url }}"
54+
55+
- name: Prepare commit
56+
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')
57+
run: sudo chown -Rc $UID .git/
58+
- name: Commit and push applied lint fixes
59+
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')
60+
uses: stefanzweifel/git-auto-commit-action@3ea6ae190baf489ba007f7c92608f33ce20ef04a
61+
with:
62+
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
63+
commit_message: "Apply lint fixes"

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,6 @@ Thumbs.db
2222
# Node
2323
node_modules
2424
npm-debug.log
25+
26+
# Lint
27+
megalinter-reports/

.jscpd.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"threshold": 0,
3+
"reporters": ["html", "markdown"],
4+
"ignore": [
5+
"**/node_modules/**",
6+
"**/.git/**",
7+
"**/.rbenv/**",
8+
"**/.venv/**",
9+
"**/*cache*/**",
10+
"**/.github/**",
11+
"**/.idea/**",
12+
"**/report/**",
13+
"**/*.svg"
14+
]
15+
}

.mega-linter.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
APPLY_FIXES: all
2+
DEFAULT_BRANCH: main
3+
SHOW_ELAPSED_TIME: false
4+
FILEIO_REPORTER: false
5+
DISABLE:
6+
- SPELL_CSPELL

0 commit comments

Comments
 (0)