2023-05-14 08:16:13 +00:00
|
|
|
---
|
|
|
|
name: MegaLinter
|
|
|
|
|
|
|
|
permissions: read-all
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
pull_request:
|
2023-12-31 17:23:10 +00:00
|
|
|
branches:
|
|
|
|
- master
|
2023-05-14 08:16:13 +00:00
|
|
|
|
|
|
|
env:
|
|
|
|
APPLY_FIXES: none
|
|
|
|
APPLY_FIXES_EVENT: pull_request
|
|
|
|
APPLY_FIXES_MODE: commit
|
2023-12-31 17:23:10 +00:00
|
|
|
FILTER_REGEX_EXCLUDE: (mega-linter.yml)
|
2023-05-14 08:16:13 +00:00
|
|
|
DISABLE: SPELL
|
|
|
|
|
|
|
|
concurrency:
|
|
|
|
group: ${{ github.ref }}-${{ github.workflow }}
|
|
|
|
cancel-in-progress: true
|
|
|
|
|
|
|
|
jobs:
|
2023-12-31 17:23:10 +00:00
|
|
|
megalinter:
|
2023-05-14 08:16:13 +00:00
|
|
|
name: MegaLinter
|
|
|
|
runs-on: ubuntu-latest
|
2023-12-31 17:23:10 +00:00
|
|
|
|
|
|
|
permissions:
|
|
|
|
contents: write
|
|
|
|
issues: write
|
|
|
|
pull-requests: write
|
|
|
|
|
2023-05-14 08:16:13 +00:00
|
|
|
steps:
|
|
|
|
- name: Checkout Code
|
2023-12-31 17:23:10 +00:00
|
|
|
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
|
2023-05-14 08:16:13 +00:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
2023-12-31 17:23:10 +00:00
|
|
|
fetch-depth: 0
|
2023-05-14 08:16:13 +00:00
|
|
|
|
|
|
|
- name: MegaLinter
|
2023-12-31 17:23:10 +00:00
|
|
|
uses: oxsecurity/megalinter@7e042c726c68415475b05a65a686c612120a1232
|
2023-05-14 08:16:13 +00:00
|
|
|
id: ml
|
|
|
|
env:
|
|
|
|
VALIDATE_ALL_CODEBASE: true
|
|
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
|
|
|
|
- name: Archive production artifacts
|
2023-12-31 17:23:10 +00:00
|
|
|
uses: actions/upload-artifact@c7d193f32edcb7bfad88892161225aeda64e9392
|
|
|
|
if: success() || failure()
|
2023-05-14 08:16:13 +00:00
|
|
|
with:
|
|
|
|
name: MegaLinter reports
|
|
|
|
path: |
|
|
|
|
megalinter-reports
|
|
|
|
mega-linter.log
|
|
|
|
|
2023-12-31 17:23:10 +00:00
|
|
|
- name: Set APPLY_FIXES_IF var
|
|
|
|
run: |
|
|
|
|
printf 'APPLY_FIXES_IF=%s\n' "${{
|
|
|
|
steps.ml.outputs.has_updated_sources == 1 &&
|
|
|
|
(
|
|
|
|
env.APPLY_FIXES_EVENT == 'all' ||
|
|
|
|
env.APPLY_FIXES_EVENT == github.event_name
|
|
|
|
) &&
|
|
|
|
(
|
|
|
|
github.event_name == 'push' ||
|
|
|
|
github.event.pull_request.head.repo.full_name == github.repository
|
|
|
|
)
|
|
|
|
}}" >> "${GITHUB_ENV}"
|
|
|
|
|
|
|
|
- name: Set APPLY_FIXES_IF_* vars
|
|
|
|
run: |
|
|
|
|
printf 'APPLY_FIXES_IF_PR=%s\n' "${{
|
|
|
|
env.APPLY_FIXES_IF == 'true' &&
|
|
|
|
env.APPLY_FIXES_MODE == 'pull_request'
|
|
|
|
}}" >> "${GITHUB_ENV}"
|
|
|
|
printf 'APPLY_FIXES_IF_COMMIT=%s\n' "${{
|
|
|
|
env.APPLY_FIXES_IF == 'true' &&
|
|
|
|
env.APPLY_FIXES_MODE == 'commit' &&
|
|
|
|
(!contains(fromJSON('["refs/heads/main", "refs/heads/master"]'), github.ref))
|
|
|
|
}}" >> "${GITHUB_ENV}"
|
|
|
|
|
2023-05-14 08:16:13 +00:00
|
|
|
- name: Create Pull Request with applied fixes
|
2023-12-31 17:23:10 +00:00
|
|
|
uses: peter-evans/create-pull-request@153407881ec5c347639a548ade7d8ad1d6740e38
|
2023-05-14 08:16:13 +00:00
|
|
|
id: cpr
|
2023-12-31 17:23:10 +00:00
|
|
|
if: env.APPLY_FIXES_IF_PR == 'true'
|
2023-05-14 08:16:13 +00:00
|
|
|
with:
|
|
|
|
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
|
|
|
|
commit-message: "[MegaLinter] Apply linters automatic fixes"
|
|
|
|
title: "[MegaLinter] Apply linters automatic fixes"
|
|
|
|
labels: bot
|
2023-12-31 17:23:10 +00:00
|
|
|
|
2023-05-14 08:16:13 +00:00
|
|
|
- name: Create PR output
|
2023-12-31 17:23:10 +00:00
|
|
|
if: env.APPLY_FIXES_IF_PR == 'true'
|
2023-05-14 08:16:13 +00:00
|
|
|
run: |
|
2023-12-31 17:23:10 +00:00
|
|
|
echo "PR Number - ${{ steps.cpr.outputs.pull-request-number }}"
|
|
|
|
echo "PR URL - ${{ steps.cpr.outputs.pull-request-url }}"
|
2023-05-14 08:16:13 +00:00
|
|
|
|
|
|
|
- name: Prepare commit
|
2023-12-31 17:23:10 +00:00
|
|
|
if: env.APPLY_FIXES_IF_COMMIT == 'true'
|
2023-05-14 08:16:13 +00:00
|
|
|
run: sudo chown -Rc $UID .git/
|
2023-12-31 17:23:10 +00:00
|
|
|
|
2023-05-14 08:16:13 +00:00
|
|
|
- name: Commit and push applied linter fixes
|
2023-12-31 17:23:10 +00:00
|
|
|
uses: stefanzweifel/git-auto-commit-action@8756aa072ef5b4a080af5dc8fef36c5d586e521d
|
|
|
|
if: env.APPLY_FIXES_IF_COMMIT == 'true'
|
2023-05-14 08:16:13 +00:00
|
|
|
with:
|
2023-12-31 17:23:10 +00:00
|
|
|
branch: >-
|
|
|
|
${{
|
|
|
|
github.event.pull_request.head.ref ||
|
|
|
|
github.head_ref ||
|
|
|
|
github.ref
|
|
|
|
}}
|
2023-05-14 08:16:13 +00:00
|
|
|
commit_message: "[MegaLinter] Apply linters fixes"
|
2023-12-31 17:23:10 +00:00
|
|
|
commit_user_name: "github-actions"
|
|
|
|
commit_user_email: "github-actions[bot]@users.noreply.github.com"
|