Buckets:

download
raw
3.62 kB
#!/usr/bin/env python3
"""
GitHub Failed Workflow Logs Fetcher
"""
import time
import jwt
import requests
CONFIG = {
"app_id": "2872904",
"key_path": "/root/.ssh/github-app-zenai.pem",
"owner": "SHAdd0WTAka",
"repo": "Zen-Ai-Pentest",
}
def generate_jwt(app_id, key_path):
with open(key_path, "r") as f:
private_key = f.read()
payload = {
"iat": int(time.time()),
"exp": int(time.time()) + 600,
"iss": app_id,
}
return jwt.encode(payload, private_key, algorithm="RS256")
def get_installation_token(jwt_token, owner, repo):
headers = {
"Authorization": f"Bearer {jwt_token}",
"Accept": "application/vnd.github.v3+json",
}
resp = requests.get(f"https://api.github.com/repos/{owner}/{repo}/installation", headers=headers, timeout=30)
if resp.status_code != 200:
return None
installation_id = resp.json()["id"]
resp = requests.post(
f"https://api.github.com/app/installations/{installation_id}/access_tokens", headers=headers, timeout=30
)
return resp.json()["token"] if resp.status_code == 201 else None
if __name__ == "__main__":
jwt_token = generate_jwt(CONFIG["app_id"], CONFIG["key_path"])
token = get_installation_token(jwt_token, CONFIG["owner"], CONFIG["repo"])
if not token:
print("❌ Kein Token")
exit(1)
headers = {
"Authorization": f"token {token}",
"Accept": "application/vnd.github.v3+json",
}
# Hole alle Workflow Runs mit verschiedenen Status
print("🔍 Prüfe Workflow Runs...\n")
for status in ["failure", "in_progress", "queued", "action_required"]:
resp = requests.get(
f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/actions/runs",
headers=headers,
params={"status": status, "per_page": 5},
timeout=30,
)
if resp.status_code == 200:
runs = resp.json()["workflow_runs"]
if runs:
print(f"\n{'=' * 60}")
print(f"📊 STATUS: {status.upper()} ({len(runs)} runs)")
print("=" * 60)
for run in runs:
print(f"\n📝 {run['name']}")
print(f" Branch: {run['head_branch']}")
print(f" Event: {run['event']}")
print(f" Created: {run['created_at']}")
print(f" URL: {run['html_url']}")
# Hole Jobs für diesen Run
jobs_resp = requests.get(
f"https://api.github.com/repos/{CONFIG['owner']}/{CONFIG['repo']}/actions/runs/{run['id']}/jobs",
headers=headers,
timeout=30,
)
if jobs_resp.status_code == 200:
jobs = jobs_resp.json()["jobs"]
for job in jobs:
status_icon = (
"✅" if job["conclusion"] == "success" else ("❌" if job["conclusion"] == "failure" else "⏳")
)
print(f" {status_icon} Job: {job['name']} - {job['status']} ({job.get('conclusion', 'N/A')})")
# Zeige fehlgeschlagene Steps
if job["conclusion"] == "failure":
for step in job["steps"]:
if step["conclusion"] == "failure":
print(f" ❌ FAILED STEP: {step['name']}")

Xet Storage Details

Size:
3.62 kB
·
Xet hash:
c252939391fc92a3e6d0f36b3d7853d6f7ea5e5a1f37e11ffe52f580f6b493e3

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.