@@ -159,23 +159,33 @@ def check_project_actions(repository: str | os.PathLike, approved_patterns_file:
159159 failures .append (f"❌ { relative_path } { yaml_path } : '{ uses_value } ' is not approved" )
160160
161161 if on_gha ():
162+ summary_lines : list [str ] = [
163+ "# GitHub Actions verification result" ,
164+ "" ,
165+ "For more information visit the [ASF Infrastructure GitHub Actions Policy](https://infra.apache.org/github-actions-policy.html) page" ,
166+ "and the [ASF Infrastructure Actions](https://github.com/apache/infrastructure-actions) repository." ,
167+ ]
168+
169+ if len (failures ) > 0 :
170+ summary_lines .extend (["" , f"## Failures ({ len (failures )} )" ])
171+ for msg in failures :
172+ summary_lines .extend ([msg , "" ])
173+
174+ if len (warnings ) > 0 :
175+ summary_lines .extend (["" , f"## Warnings ({ len (warnings )} )" ])
176+ for msg in warnings :
177+ summary_lines .extend ([msg , "" ])
178+
179+ if len (failures ) == 0 :
180+ summary_lines .append ("✅ Success, all action usages match the currently approved patterns." )
181+
182+ summary_text = "\n " .join (summary_lines ).rstrip () + "\n "
183+
162184 with open (os .environ ["GITHUB_STEP_SUMMARY" ], "a" ) as f :
163- f .write (f"# GitHub Actions verification result\n " )
164- f .write ("\n " )
165- f .write ("For more information visit the [ASF Infrastructure GitHub Actions Policy](https://infra.apache.org/github-actions-policy.html) page\n " )
166- f .write ("and the [ASF Infrastructure Actions](https://github.com/apache/infrastructure-actions) repository.\n " )
167- if len (failures ) > 0 :
168- f .write ("\n " )
169- f .write (f"## Failures ({ len (failures )} )\n " )
170- for msg in failures :
171- f .write (f"{ msg } \n \n " )
172- if len (warnings ) > 0 :
173- f .write ("\n " )
174- f .write (f"## Warnings ({ len (warnings )} )\n " )
175- for msg in warnings :
176- f .write (f"{ msg } \n \n " )
177- if len (failures ) == 0 :
178- f .write (f"✅ Success, all action usages match the currently approved patterns.\n " )
185+ f .write (summary_text )
186+ # This file is used in the workflow to post a comment on a pull request.
187+ with open ("step-summary-output.txt" , "a" ) as f :
188+ f .write (summary_text )
179189
180190 if len (failures ) > 0 :
181191 raise Exception (f"One or more action references are not approved or explicitly blocked:\n { "\n " .join (failures )} " )
0 commit comments