Spaces:
Runtime error
Runtime error
alamin655
commited on
Commit
•
4cabe21
1
Parent(s):
c37a9b4
Create mega-linter.yml
Browse files
.github/workflows/mega-linter.yml
ADDED
@@ -0,0 +1,91 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
---
|
2 |
+
# MegaLinter GitHub Action configuration file
|
3 |
+
# More info at https://megalinter.io
|
4 |
+
name: MegaLinter
|
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: [rolling]
|
11 |
+
|
12 |
+
env: # Comment env block if you don't want to apply fixes
|
13 |
+
# Apply linter fixes configuration
|
14 |
+
APPLY_FIXES: all # When active, APPLY_FIXES must also be defined as environment variable (in github/workflows/mega-linter.yml or other CI tool)
|
15 |
+
APPLY_FIXES_EVENT: pull_request # Decide which event triggers application of fixes in a commit or a PR (pull_request, 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 |
+
concurrency:
|
19 |
+
group: ${{ github.ref }}-${{ github.workflow }}
|
20 |
+
cancel-in-progress: true
|
21 |
+
|
22 |
+
jobs:
|
23 |
+
build:
|
24 |
+
name: MegaLinter
|
25 |
+
runs-on: ubuntu-latest
|
26 |
+
permissions:
|
27 |
+
# Give the default GITHUB_TOKEN write permission to commit and push, comment issues & post new PR
|
28 |
+
# Remove the ones you do not need
|
29 |
+
contents: write
|
30 |
+
issues: write
|
31 |
+
pull-requests: write
|
32 |
+
steps:
|
33 |
+
# Git Checkout
|
34 |
+
- name: Checkout Code
|
35 |
+
uses: actions/checkout@v3
|
36 |
+
with:
|
37 |
+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
38 |
+
fetch-depth: 0 # If you use VALIDATE_ALL_CODEBASE = true, you can remove this line to improve performances
|
39 |
+
|
40 |
+
# MegaLinter
|
41 |
+
- name: MegaLinter
|
42 |
+
id: ml
|
43 |
+
# You can override MegaLinter flavor used to have faster performances
|
44 |
+
# More info at https://megalinter.io/flavors/
|
45 |
+
uses: oxsecurity/megalinter@v7
|
46 |
+
env:
|
47 |
+
# All available variables are described in documentation
|
48 |
+
# https://megalinter.io/configuration/
|
49 |
+
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
|
50 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
51 |
+
# ADD YOUR CUSTOM ENV VARIABLES HERE OR DEFINE THEM IN A FILE .mega-linter.yml AT THE ROOT OF YOUR REPOSITORY
|
52 |
+
# DISABLE: COPYPASTE,SPELL # Uncomment to disable copy-paste and spell checks
|
53 |
+
|
54 |
+
# Upload MegaLinter artifacts
|
55 |
+
- name: Archive production artifacts
|
56 |
+
if: ${{ success() }} || ${{ failure() }}
|
57 |
+
uses: actions/upload-artifact@v3
|
58 |
+
with:
|
59 |
+
name: MegaLinter reports
|
60 |
+
path: |
|
61 |
+
megalinter-reports
|
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_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
68 |
+
uses: peter-evans/create-pull-request@v5
|
69 |
+
with:
|
70 |
+
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
71 |
+
commit-message: "[MegaLinter] Apply linters automatic fixes"
|
72 |
+
title: "[MegaLinter] 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_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
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_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
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_name == 'push' || github.event.pull_request.head.repo.full_name == github.repository) && !contains(github.event.head_commit.message, 'skip fix')
|
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: "[MegaLinter] Apply linters fixes"
|
90 |
+
commit_user_name: megalinter-bot
|
91 |
+
commit_user_email: [email protected]
|