github.com/iter8-tools/iter8@v1.1.2/.github/workflows/lintcharts.yaml (about)

     1  name: Lint Helm charts
     2  
     3  # Only runs when charts have changed
     4  
     5  # Lint Helm charts
     6  
     7  on:
     8    pull_request:
     9      branches:
    10      - master
    11      paths:
    12      - charts/**
    13  
    14  jobs:
    15    # Get the paths for the Helm charts to lint
    16    get_paths:
    17      runs-on: ubuntu-latest
    18  
    19      steps:
    20      - uses: actions/checkout@v4
    21        with:
    22          fetch-depth: 0
    23  
    24      - name: Get the paths for Helm charts to lint
    25        id: set-matrix
    26        run: |
    27          # Get paths (in string form)
    28          stringPaths=$(find -maxdepth 2 -path './charts/*')
    29  
    30          # Check paths (length greater than 0)
    31          stringPathsLength=$(echo ${#stringPaths})
    32          if (( stringPathsLength == 0 ));
    33          then
    34            echo "No paths to check"
    35            exit 1
    36          fi
    37  
    38          # Serialize paths into JSON array
    39          paths=$(jq -ncR '[inputs]' <<< "$stringPaths")
    40  
    41          # Output serialized paths
    42          echo "matrix=$paths" >> $GITHUB_OUTPUT
    43          echo $paths
    44  
    45      outputs:
    46        matrix: ${{ steps.set-matrix.outputs.matrix }}
    47  
    48    # Lint Helm charts based on paths provided by previous job
    49    lint:
    50      name: Test changed-files
    51      needs: get_paths
    52      runs-on: ubuntu-latest
    53      strategy:
    54        matrix:
    55          version: ${{ fromJson(needs.get_paths.outputs.matrix) }}
    56      steps:
    57        - uses: actions/checkout@v4
    58          with:
    59            fetch-depth: 0
    60  
    61        - name: Get modified files in the ${{ matrix.version }} folder
    62          id: modified-files
    63          uses: tj-actions/changed-files@v41
    64          with:
    65            files: ${{ matrix.version }}
    66  
    67        - name: Lint Helm charts in the ${{ matrix.version }} folder
    68          uses: stackrox/kube-linter-action@v1
    69          if: steps.modified-files.outputs.any_modified == 'true'
    70          with:
    71            directory: ${{ matrix.version }}