name: E2ECleanup
on:
  workflow_dispatch:
    inputs:
      cluster_name:
        type: string
        required: true
      git_ref:
        type: string
      region:
        type: choice
        options:
          - "us-east-1"
          - "us-east-2"
          - "us-west-2"
          - "eu-west-1"
jobs:
  cleanup:
    permissions:
      id-token: write # aws-actions/configure-aws-credentials@v4.0.1
    name: cleanup-${{ inputs.cluster_name }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 # v4.1.2
        with:
          ref: ${{ inputs.git_ref }}
      - name: configure aws credentials
        uses: aws-actions/configure-aws-credentials@e3dd6a429d7300a6a4c196c26e071d42e0343502 # v4.0.2
        with:
          role-to-assume: arn:aws:iam::${{ vars.CI_ACCOUNT_ID }}:role/${{ vars.CI_ROLE_NAME }}
          aws-region: ${{ inputs.region }}
          role-duration-seconds: 21600
      - name: cleanup karpenter and cluster '${{ inputs.cluster_name }}' resources
        uses: ./.github/actions/e2e/cleanup
        with:
          account_id: ${{ vars.CI_ACCOUNT_ID }}
          role: ${{ vars.CI_ROLE_NAME }}
          region: ${{ inputs.region }}
          cluster_name: ${{ inputs.cluster_name }}
          git_ref: ${{ inputs.git_ref }}
          eksctl_version: v0.191.0
