Skip to content

Commit b4392f9

Browse files
committed
Use Actions-based linter
1 parent dbc5e4a commit b4392f9

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed

.github/workflows/lint.yml

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

0 commit comments

Comments
 (0)