@@ -63,8 +63,10 @@ def wait_for_workflow_run(
6363 raise Exception ("Timed out waiting for workflow run" )
6464
6565
66- def on_run_finished (owner : str , repo : str , run : github .WorkflowRun ) -> None :
66+ def on_run_finished (owner : str , repo : str , run : github .WorkflowRun , do_summary : bool ) -> None :
6767 if run .is_successful ():
68+ if do_summary :
69+ util .gh_summary ("✅ Run finished successfully" )
6870 util .log (
6971 "Workflow run finished successfully:\n "
7072 f" ID: { run .id } \n "
@@ -74,6 +76,8 @@ def on_run_finished(owner: str, repo: str, run: github.WorkflowRun) -> None:
7476 )
7577 else :
7678 failed_steps = _get_failed_steps (owner , repo , run .id )
79+ if do_summary :
80+ util .gh_summary (f"❌ Run failed\n Failed steps:{ failed_steps } " )
7781 raise Exception (
7882 "Workflow run failed:\n "
7983 f" ID: { run .id } \n "
@@ -95,9 +99,7 @@ def _get_failed_steps(owner: str, repo: str, run_id: int) -> str:
9599 for step in job .steps :
96100 if not step .is_failed ():
97101 continue
98- result += f"\n { step .name } "
99- result += f"\n Status: { step .status } "
100- result += f"\n Conclusion: { step .conclusion } "
102+ result += f"\n - { step .name } (status: { step .status } , conclusion: { step .conclusion } )"
101103 return result
102104
103105
@@ -128,11 +130,12 @@ def main(
128130 if do_summary :
129131 util .gh_summary (
130132 f"Dispatched run: [{ run .id } ]({ run .html_url } )\n "
131- f"Workflow: [{ workflow } ](https://github.com/{ owner } /{ repo } /blob/{ ref } /.github/workflows/{ workflow } ) in { owner } /{ repo } @{ ref } \n "
133+ f"Repository: { owner } /{ repo } @{ ref } \n "
134+ f"Workflow: [{ workflow } ](https://github.com/{ owner } /{ repo } /blob/{ ref } /.github/workflows/{ workflow } )\n "
132135 f"Inputs:\n ```\n { json .dumps (workflow_inputs , indent = 2 )} \n ```"
133136 )
134137 if run .is_finished ():
135- on_run_finished (owner , repo , run )
138+ on_run_finished (owner , repo , run , do_summary )
136139 return
137140 wait_for_workflow_run (owner , repo , run .id , poll_interval , run_timeout_seconds )
138141
0 commit comments