Files
factorio/create-ci-kubeconfig.sh
feedc0de d1978abb05
Test and deploy Factorio / validate (push) Failing after 12s
Test and deploy Factorio / deploy (push) Skipped
Deploy achievement-safe Factorio 2.0.77 with strict placement, monitoring and limited CD
2026-10-17 13:50:19 +02:00

12 lines
925 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
[[ $(kubectl config current-context) == kubernetes-admin@kubernetes ]] || { echo 'Wrong Kubernetes context' >&2; exit 1; }
python3 - <<'PY'
import base64,json,subprocess
get=lambda *args: json.loads(subprocess.check_output(['kubectl',*args]))
cluster=get('config','view','--minify','-o','json')['clusters'][0]['cluster']
secret=get('-n','factorio','get','secret','factorio-deployer-token','-o','json')['data']
config={'apiVersion':'v1','kind':'Config','clusters':[{'name':'cluster','cluster':{'server':cluster['server'],'certificate-authority-data':secret['ca.crt']}}], 'users':[{'name':'factorio-deployer','user':{'token':base64.b64decode(secret['token']).decode()}}], 'contexts':[{'name':'factorio-ci','context':{'cluster':'cluster','user':'factorio-deployer','namespace':'factorio'}}], 'current-context':'factorio-ci'}
print(base64.b64encode(json.dumps(config).encode()).decode())
PY