ci: label Type/State/Category (fix indent + debug PARSED)
This commit is contained in:
@@ -8,7 +8,7 @@ jobs:
|
||||
label:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Apply labels from Type/State
|
||||
- name: Apply labels from Type/State/Category
|
||||
env:
|
||||
FORGE_BASE: ${{ vars.FORGE_API || vars.FORGE_BASE }}
|
||||
FORGE_TOKEN: ${{ secrets.FORGE_TOKEN }}
|
||||
@@ -33,28 +33,35 @@ jobs:
|
||||
if not number:
|
||||
raise SystemExit("No issue number/index in event payload")
|
||||
|
||||
def pick_line(key):
|
||||
m = re.search(rf"^{re.escape(key)}:\s*([^\n\r]+)", body, flags=re.M)
|
||||
def pick_line(key: str) -> str:
|
||||
m = re.search(rf"^\s*{re.escape(key)}\s*:\s*([^\n\r]+)", body, flags=re.M)
|
||||
return m.group(1).strip() if m else ""
|
||||
|
||||
desired = set()
|
||||
|
||||
t = pick_line("Type")
|
||||
s = pick_line("State")
|
||||
c = pick_line("Category")
|
||||
|
||||
# 1) Type / State explicit (depuis le site)
|
||||
if t: desired.add(t)
|
||||
if s: desired.add(s)
|
||||
print("PARSED:", {"Type": t, "State": s, "Category": c})
|
||||
|
||||
# 2) Fallback depuis le titre si besoin
|
||||
# 1) explicite depuis le body
|
||||
if t:
|
||||
desired.add(t)
|
||||
if s:
|
||||
desired.add(s)
|
||||
if c:
|
||||
desired.add(c)
|
||||
|
||||
# 2) fallback depuis le titre si Type absent
|
||||
if not t:
|
||||
if title.startswith("[Correction]"):
|
||||
desired.add("type/correction")
|
||||
elif title.startswith("[Fact-check]") or title.startswith("[Vérification]"):
|
||||
desired.add("type/fact-check")
|
||||
|
||||
# 3) fallback State si absent
|
||||
if not s:
|
||||
# état par défaut si absent
|
||||
if "type/fact-check" in desired:
|
||||
desired.add("state/a-sourcer")
|
||||
elif "type/correction" in desired:
|
||||
@@ -76,7 +83,7 @@ jobs:
|
||||
data = None if payload is None else json.dumps(payload).encode("utf-8")
|
||||
req = urllib.request.Request(url, data=data, headers=headers, method=method)
|
||||
try:
|
||||
with urllib.request.urlopen(req) as r:
|
||||
with urllib.request.urlopen(req, timeout=20) as r:
|
||||
b = r.read()
|
||||
return json.loads(b.decode("utf-8")) if b else None
|
||||
except urllib.error.HTTPError as e:
|
||||
|
||||
Reference in New Issue
Block a user