fix(cd): 校验候选部署入口并隔离凭据
build / build (push) Successful in 1m30s

This commit is contained in:
姚章浩
2026-11-23 13:28:40 +08:00
parent 1beaa31771
commit 0246db357f
4 changed files with 23 additions and 14 deletions
+17 -4
View File
@@ -59,9 +59,22 @@ jobs:
test "$GITHUB_EVENT_NAME" = workflow_dispatch
test "$GITHUB_REF" = refs/heads/main
test -n "$KG_CANDIDATE_ACCESS"
python3 -c '
python3 - <<'PY'
import json, os, sys
with open(os.environ["GITHUB_EVENT_PATH"]) as source:
from urllib.error import HTTPError
from urllib.request import ProxyHandler, Request, build_opener
with open(os.environ['GITHUB_EVENT_PATH']) as source:
event = json.load(source)
print(json.dumps({"run": os.environ["GITHUB_RUN_ID"], "plan": json.loads(event["inputs"]["plan"])}))
' | curl --noproxy '*' --silent --show-error --fail-with-body --max-time 2540 -H "Authorization: Bearer $KG_CANDIDATE_ACCESS" -H 'Content-Type: application/json' -X POST --data-binary @- http://127.0.0.1:38984/prepare
if event.get('inputs', {}).get('mode') != 'prepare':
sys.exit('candidate workflow mode is not prepare')
data = json.dumps({'run': os.environ['GITHUB_RUN_ID'], 'plan': json.loads(event['inputs']['plan'])}).encode()
request = Request('http://127.0.0.1:38984/prepare', data=data, headers={
'Authorization': 'Bearer ' + os.environ['KG_CANDIDATE_ACCESS'], 'Content-Type': 'application/json'})
opener = build_opener(ProxyHandler({}))
try:
with opener.open(request, timeout=2540) as response:
print(response.read(65536).decode())
except HTTPError as exc:
print(exc.read(4096).decode(), file=sys.stderr)
sys.exit(1)
PY