# Right now the trigger is set to run on every Monday at 13:00 UTC,
# or when the workflow file is modified. An additional manual trigger
# is also available.
name: "Validate Helm Charts downloads"

on:
  schedule:
    # Run every Monday at 13:00 UTC
    - cron: "0 13 * * 1"
  pull_request:
    paths:
      - ".github/workflows/test_helm_charts.yaml"
      - "scripts/helm-validate.py"
  push:
    paths:
      - ".github/workflows/test_helm_charts.yaml"
      - "scripts/helm-validate.py"
  workflow_dispatch:

jobs:
  test-helm-charts:
    name: "Helm Charts Validation"
    runs-on: ubuntu-latest
    steps:
      - name: "Checkout Infrastructure"
        uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - name: Set up Python
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"
      - name: Install additional Python dependencies
        run: |
          pip install python-hcl2
          pip install tqdm
      - name: Install nebari
        run: |
          pip install .
      - name: Install Helm
        run: |
          curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/master/scripts/get-helm-3
          chmod 700 get_helm.sh
          ./get_helm.sh
      - name: Test Helm installation
        run: |
          helm version
      - name: Test Helm Charts
        run: |
          python scripts/helm-validate.py
