import * as core from "@actions/core" ; import * as path from "path" ; import * as fs from "fs" ; import { Cluster , parseCluster } from "./types/cluster" ; import { setContext , getKubeconfig } from "./utils" ; /**
 * Sets the Kubernetes context based on supplied action inputs
 */ export async function run ( ) { const clusterType = parseCluster ( core . getInput ( "cluster-type" , { required : true , } ) ) ; const runnerTempDirectory = process . env [ "RUNNER_TEMP" ] ; const kubeconfigPath = path . join ( runnerTempDirectory , `kubeconfig_${ Date . now ( ) }` ) ; const kubeconfig = await getKubeconfig ( clusterType ) ; const kubeconfigWithContext = setContext ( kubeconfig ) ; core . debug ( `Writing kubeconfig contents to ${ kubeconfigPath }` ) ; fs . writeFileSync ( kubeconfigPath , kubeconfigWithContext ) ; fs . chmodSync ( kubeconfigPath , "600" ) ; core . debug ( "Setting KUBECONFIG environment variable" ) ; core . exportVariable ( "KUBECONFIG" , kubeconfigPath ) ; } run ( ) . catch ( core . setFailed ) ;