name: Lint

on:
  pull_request:
  push:

jobs:
  lint:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        helm_version: [3.11.1]
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          path: harbor

      - name: Set up Helm
        uses: azure/setup-helm@v1
        with:
          version: '${{ matrix.helm_version }}'

      - name: Helm version
        run:
          helm version -c

      - name: Run lint
        continue-on-error: ${{ startsWith(matrix.helm_version, '2.') }}
        working-directory: ./harbor
        run:
          helm lint .

      - name: Update dependency
        working-directory: ./harbor
        run:
          helm dependency update .

      - name: Run template for ingress expose
        working-directory: ./harbor
        run:
          helm template --set "expose.type=ingress" --output-dir $(mktemp -d -t output-XXXXXXXXXX) .

      - name: Run template for nodePort expose
        working-directory: ./harbor
        run:
          helm template --set "expose.type=nodePort,expose.tls.auto.commonName=127.0.0.1" --output-dir $(mktemp -d -t output-XXXXXXXXXX) .
