Fail the bump run when a pull request can't be opened (#31)
The run printed 'opened' even when gh pr create failed (for example when Actions may not create pull requests), so a pushed branch could sit with no pull request and a green run.
This commit is contained in:
1 parent
5796d0eebb
commit
1bef43c3d6
1 file changed
+9
-3
+9
-3
@@ -235,7 +235,7 @@ def run(only=()):
|
||||
if not os.environ.get("DRY"):
|
||||
for k in COOLDOWN_DAYS:
|
||||
sh("gh", "label", "create", f"bump-{k}", "--color", "0e8a16", "--description", f"Automatic {k} update", check=False)
|
||||
opened = 0
|
||||
opened = failed = 0
|
||||
start = sh("git", "branch", "--show-current").stdout.strip()
|
||||
for slug, cur, rel, k, t, images, version in candidates(only):
|
||||
if k not in COOLDOWN_DAYS or "manual" in t:
|
||||
@@ -272,13 +272,19 @@ def run(only=()):
|
||||
f"Automatic {k} update from the bump bot.\n\n- {old_ref} -> {new_ref}\n- digest `{digest}`")
|
||||
sh("git", "commit", "-q", "-m", f"{title}\n\n{body}")
|
||||
sh("git", "push", "-q", "-f", "origin", branch)
|
||||
sh("gh", "pr", "create", "--base", "main", "--head", branch, "--title", title, "--body", body,
|
||||
"--label", f"bump-{k}", check=False)
|
||||
pr = sh("gh", "pr", "create", "--base", "main", "--head", branch, "--title", title, "--body", body,
|
||||
"--label", f"bump-{k}", check=False)
|
||||
if pr.returncode:
|
||||
failed += 1
|
||||
print(f"{slug}: pushed {branch} but could not open the pull request: {pr.stderr.strip()}")
|
||||
continue
|
||||
opened += 1
|
||||
print(f"{slug}: opened {title}")
|
||||
if start and not os.environ.get("DRY"):
|
||||
sh("git", "switch", "-q", start, check=False)
|
||||
print(f"{opened} pull requests opened")
|
||||
if failed:
|
||||
sys.exit(f"{failed} pull requests could not be opened")
|
||||
|
||||
|
||||
# ---- guard -----------------------------------------------------------------------------------
|
||||
|
||||
Reference in new issue
Block a user