name: InstallPrometheus
description: 'Installs prometheus'
inputs:
  account_id:
    description: "Account ID to access AWS"
    required: true
  role:
    description: "Role to access AWS"
    required: true
  region:
    description: "Region to access AWS"
    required: true
  prometheus_region:
    description: "Prometheus region"
    required: true
  cluster_name:
    description: 'Name of the cluster to be launched by eksctl'
    required: true
  workspace_id:
    description: "Id of the prometheus remote_write workspace"
    required: true
  git_ref:
    description: "The git commit, tag, or branch to check out. Requires a corresponding Karpenter snapshot release"
  private_cluster:
    description: "Whether the cluster is private or not. Valid values are 'true' or 'false'"
    default: 'false'
runs:
  using: "composite"
  steps:
    - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
      with:
        ref: ${{ inputs.git_ref }}
    - uses: ./.github/actions/e2e/install-helm
      with:
        version: v3.12.3 # Pinned to this version since v3.13.0 has issues with anonymous pulls: https://github.com/helm/helm/issues/12423
    - name: add prometheus repo
      shell: bash
      run: |
        helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
    - name: create prometheus namespace
      shell: bash
      run: |
        kubectl create ns prometheus || true
        kubectl label ns prometheus scrape=enabled --overwrite=true
    - name: install prometheus
      shell: bash
      env:
        PROMETHEUS_REGION: ${{ inputs.prometheus_region }}
        REGION: ${{ inputs.region }}
        WORKSPACE_ID: ${{ inputs.workspace_id }}
        ACCOUNT_ID: ${{ inputs.account_id }}
        CLUSTER_NAME: ${{ inputs.cluster_name }}
        PRIVATE_CLUSTER: ${{ inputs.private_cluster }}
      run: |
        ./test/hack/e2e_scripts/install_prometheus.sh