name: Verify Helm Chart
on:
  pull_request_target:
    branches:
      - main
      - bitnami-labs:main
    types:
      - opened
      - synchronize
      - reopened
    paths:
       - 'helm/**'

env:
  CSP_API_URL: https://console.cloud.vmware.com
  CSP_API_TOKEN: ${{ secrets.CSP_API_TOKEN }}
  VIB_PUBLIC_URL: https://cp.bromelia.vmware.com

jobs:
  # make sure chart is linted/safe
  vib-validate:
    runs-on: ubuntu-latest
    name: Lint chart
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{github.event.pull_request.head.ref}}
          repository: ${{github.event.pull_request.head.repo.full_name}}
      - uses: vmware-labs/vmware-image-builder-action@0.2.0

  # verify chart in multiple target platforms
  vib-k8s-verify:
    runs-on: ubuntu-latest
    environment: vmware-image-builder
    needs: [ vib-validate ]
    strategy:
      matrix:
       include:
         - target-platform: gke
           target-platform-id: 91d398a2-25c4-4cda-8732-75a3cfc179a1
      fail-fast: false
    name: Verify chart in ${{ matrix.target-platform}}
    steps:
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.ref }}
          repository: ${{ github.event.pull_request.head.repo.full_name }}
      - uses: vmware-labs/vmware-image-builder-action@0.2.0
        with:
          pipeline: vib-platform-verify.json
        env:
          TARGET_PLATFORM: ${{ matrix.target-platform-id }}
