40 lines
1.4 KiB
Python
40 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""Deploy a minimal page to every site in netlify_bank.jsonl and verify HTTP 200."""
|
|
import json, os, sys, time, urllib.request
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
from netlify_farm import api_call, deploy_static
|
|
|
|
BANK = os.environ.get('NETLIFY_BANK', os.path.join(os.path.dirname(os.path.abspath(__file__)), 'netlify_bank.jsonl'))
|
|
recs = [json.loads(l) for l in open(BANK, encoding='utf-8') if l.strip()]
|
|
ok = 0
|
|
for r in recs:
|
|
sid, tok = r.get('site_id'), r.get('token')
|
|
if not sid or not tok:
|
|
continue
|
|
try:
|
|
api_call(tok, f'/api/v1/sites/{sid}', 'PATCH',
|
|
{'sso_login': False, 'account_sso_login': False})
|
|
except Exception:
|
|
pass
|
|
good, dep = deploy_static(tok, sid, f"<html><body><h1>{r['email']}</h1></body></html>")[:2]
|
|
time.sleep(1)
|
|
code = 0
|
|
dom = r.get('site_domain')
|
|
for _ in range(6):
|
|
if not dom:
|
|
break
|
|
try:
|
|
with urllib.request.urlopen('https://' + dom, timeout=12) as resp:
|
|
code = resp.status
|
|
except urllib.error.HTTPError as e:
|
|
code = e.code
|
|
except Exception:
|
|
code = 0
|
|
if code == 200:
|
|
break
|
|
time.sleep(5)
|
|
print(f"{r['email']:<40} deploy={'ok' if good else 'FAIL'} http={code}")
|
|
if code == 200:
|
|
ok += 1
|
|
print(f'\nlive: {ok}/{len(recs)}')
|