scripts/update_status.py aktualisiert
This commit is contained in:
@@ -76,17 +76,28 @@ def safe_cell(text):
|
||||
|
||||
|
||||
def api_runs(owner, repo, workflow, page, limit=50):
|
||||
# Workflow-scoped API: avoids misreading another workflow in the repository.
|
||||
path = '/repos/{}/{}/actions/workflows/{}/runs?branch={}&page={}&limit={}'.format(
|
||||
*(urllib.parse.quote(x, safe='') for x in (owner, repo, workflow)),
|
||||
urllib.parse.quote(BRANCH, safe=''), page, limit)
|
||||
return req(path).get('workflow_runs', [])
|
||||
# Gitea 1.27: Repository-level endpoint; avoids 404 caused by
|
||||
# guessed/nonexistent workflow filenames.
|
||||
path = '/repos/{}/{}/actions/runs?{}' .format(
|
||||
urllib.parse.quote(owner, safe=''),
|
||||
urllib.parse.quote(repo, safe=''),
|
||||
urllib.parse.urlencode({'page': page, 'limit': limit}))
|
||||
result = req(path)
|
||||
runs = result.get('workflow_runs', [])
|
||||
if workflow:
|
||||
# Gitea run.path is typically .gitea/workflows/<filename>@<branch>.
|
||||
# Restrict to configured workflow, never show a different workflow as success.
|
||||
def matches(run):
|
||||
name = str(run.get('path') or '').split('@', 1)[0].rsplit('/', 1)[-1]
|
||||
return name == workflow
|
||||
runs = [run for run in runs if matches(run)]
|
||||
return runs
|
||||
|
||||
|
||||
def source_status(cfg, source):
|
||||
owner = source.get('owner', cfg['owner'])
|
||||
repo = source['repo']
|
||||
workflow = source['workflow']
|
||||
workflow = source.get('workflow')
|
||||
limit_age = dt.timedelta(hours=source.get('max_age_hours', cfg.get('max_age_hours', 26)))
|
||||
all_runs = []
|
||||
# Up to 250 runs; sufficient for typical daily sources, can be adjusted.
|
||||
@@ -130,7 +141,7 @@ def main():
|
||||
for src in cfg['sources']:
|
||||
owner = src.get('owner', cfg['owner'])
|
||||
repo = src['repo']
|
||||
workflow = src['workflow']
|
||||
workflow = src.get('workflow')
|
||||
name = src['name']
|
||||
url = BASE + '/' + urllib.parse.quote(owner) + '/' + urllib.parse.quote(repo) + '/actions'
|
||||
try:
|
||||
@@ -151,7 +162,7 @@ def main():
|
||||
'- 🔴 Fehlgeschlagen: Der neueste Workflow ist gescheitert.\n'
|
||||
'- ⚠️ Überfällig: Es gibt keinen ausreichend aktuellen erfolgreichen Lauf, auch wenn der letzte alte Lauf grün war.\n'
|
||||
'- 🔵 Läuft / 🟡 Wartet: Der neueste Lauf ist noch nicht abgeschlossen.\n'
|
||||
'- ❌ API-Fehler: Quelle, Workflowname, Tokenrechte oder API prüfen.\n'
|
||||
'- ❌ API-Fehler: Repository, Tokenrechte oder API prüfen.\n'
|
||||
'- Die Dauer bezieht sich auf den zuletzt gestarteten Lauf, soweit Start- und Endzeit vorliegen.\n'
|
||||
'- Status und Zeitangaben werden alle 15 Minuten oder manuell aktualisiert.\n\n'
|
||||
'## Links\n\n'
|
||||
|
||||
Reference in New Issue
Block a user