@@ -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
|
||||
|
||||
Reference in New Issue
Block a user