1

I am pretty new for github actions workflow. I have the following question.

What I have:

  • Have a repo with subfolders folder1/dotnet and folder2/dotnet

What I want to Achieve:

  • I want to crate github workflow which will lint only folder1 and folder 2 when new code is pushed to specific folder

Currently bellow code lints entire repo

name: pr_dotnet

on:
  push:
    paths:
      - "folder1/dotnet/**"
      - "folder2/dotnet/**"

jobs:
  lint:
    name: Lint dotnet specific folders
    runs-on: ubuntu-latest
    strategy:
      matrix: { dir: ['/folder1/dotnet', 'folder2/dotnet'] }

    steps:
      - name: Checkout code
        uses: actions/checkout@v3
        with:
          token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}

      - name: MegaLinter 
        uses: oxsecurity/megalinter/flavors/dotnet@v6.12.0
        working-directory: ${{matrix.dir}}

      - name: Archive linted artifacts
        if: ${{ success() }} || ${{ failure() }}
        uses: actions/upload-artifact@v2
        with:
          name: MegaLinter reports
          path: |
            megalinter-reports
            mega-linter.log

1 Answers1

0

You can run MegaLinter with a sub-workspace as root using variable DEFAULT_WORKSPACE

DEFAULT_WORKSPACE: mega-linter-runner

  - name: MegaLinter 
    uses: oxsecurity/megalinter/flavors/dotnet@v6.12.0
    env:
      DEFAULT_WORKSPACE: ${{matrix.dir}}

As MegaLinter won't browse at upper lever than DEFAULT_WORKSPACE, you may need to define one .mega-linter.yml config files by root workspace, or use EXTENDS to store the shared configuration online

Nicolas Vuillamy
  • 564
  • 7
  • 14