Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 54 additions & 1 deletion utils/verify-action-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import subprocess
import sys
import tempfile

import webbrowser
from pathlib import Path

import jsbeautifier
Expand Down Expand Up @@ -2477,6 +2477,56 @@ def show_verification_summary(
console.print(nested_table)


def offer_open_and_approve(
org: str, repo: str, commit_hash: str, sub_path: str = "",
ci_mode: bool = False,
) -> str | None:
"""Offer to open the action in a browser and/or approve it.

Returns "approve" if the user chose to approve, None otherwise.
"""
if ci_mode:
return None

action_url = f"https://github.com/{org}/{repo}/tree/{commit_hash}"
if sub_path:
action_url += f"/{sub_path}"

urls = [
("Source tree", action_url),
("Commit", f"https://github.com/{org}/{repo}/commit/{commit_hash}"),
("Repository", f"https://github.com/{org}/{repo}"),
]

console.print()
console.print("[bold]Quick links:[/bold]")
for label, url in urls:
console.print(f" [link={url}]{label}: {url}[/link]")

console.print()
console.print(
" [bold]o[/bold] = open in browser, "
"[bold]a[/bold] = approve action, "
"[bold]Enter[/bold]/[bold]q[/bold] = done"
)

while True:
try:
choice = console.input(" > ").strip().lower()
except EOFError:
break
if choice == "o":
webbrowser.open(action_url)
console.print(" [dim]Opened in browser[/dim]")
continue
if choice == "a":
return "approve"
# Enter, 'q', or anything else = done
break

return None


def verify_single_action(
action_ref: str, gh: GitHubClient | None = None, ci_mode: bool = False,
cache: bool = True, show_build_steps: bool = False,
Expand Down Expand Up @@ -2679,6 +2729,9 @@ def verify_single_action(
)
)

# Offer to open in browser and/or approve
offer_open_and_approve(org, repo, commit_hash, sub_path, ci_mode=ci_mode)

return all_match


Expand Down
Loading