@@ -28,12 +28,12 @@ const MINIMIZE_COMMENT_MUTATION = `
2828 }
2929` ;
3030
31- const COMMENT_LOOKUP = "Some formality checks failed. " ;
31+ const COMMENT_LOOKUP = "<!-- FORMALITY_LOOKUP --> " ;
3232
3333const SUMMARY_HEADER = `
3434> [!WARNING]
3535>
36- > ${ COMMENT_LOOKUP }
36+ > Some formality checks failed.
3737>
3838> Consider (re)reading [submissions guidelines](https://openwrt.org/submitting-patches#submission_guidelines).
3939
@@ -47,6 +47,14 @@ const SUMMARY_FOOTER=`
4747</details>
4848` ;
4949
50+ const NO_MODIFY = `
51+ > [!TIP]
52+ >
53+ > PR has _Allow edits and access to secrets by maintainers_ disabled. Consider allowing edits to simplify review.
54+ >
55+ > [More info](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/allowing-changes-to-a-pull-request-branch-created-from-a-fork)
56+ ` ;
57+
5058async function hideOldSummaries ( { github, owner, repo, issueNumber } ) {
5159 const result = await github . graphql ( GET_COMMENTS_QUERY , { owner, repo, issueNumber } ) ;
5260
@@ -68,27 +76,42 @@ function getJobUrl({ context, jobId }) {
6876function getSummaryMessage ( { context, jobId, summary } ) {
6977 return `
7078 ${ SUMMARY_HEADER }
71-
7279 ${ summary }
73-
7480 ${ SUMMARY_FOOTER }
7581 For more details, see the [full job log](${ getJobUrl ( { context, jobId } ) } ).
7682 ` ;
7783}
7884
79- async function processFormalities ( { github, context, jobId, summary } ) {
80- const { owner, repo } = context . repo ;
81- const issueNumber = context . issue . number ;
85+ function getCommentMessage ( { context, jobId, noModify, summary } ) {
86+ return `
87+ ${ summary . length > 0 ? getSummaryMessage ( { context, jobId, summary } ) : '' }
88+ ${ noModify ? NO_MODIFY : '' }
89+ ${ COMMENT_LOOKUP }
90+ ` ;
91+ }
92+
93+ async function processFormalities ( {
94+ context,
95+ github,
96+ jobId,
97+ summary,
98+ warnOnNoModify,
99+ } ) {
100+ const { owner, repo, number : issueNumber } = context . issue ;
82101
83102 await hideOldSummaries ( { github, owner, repo, issueNumber } ) ;
84103
104+ // Explicitly check maintainer_can_modify as it might not be set at all
105+ const { pull_request : pr } = context . payload . pull_request ;
106+ const noModify = warnOnNoModify && pr ?. maintainer_can_modify === false ;
85107 summary = summary . trim ( ) ;
86- if ( summary . length === 0 ) {
108+ if ( summary . length === 0 && ! noModify ) {
109+ console . log ( 'Summary is empty and modify checks passed, skipping posting a comment' ) ;
87110 return ;
88111 }
89112
90113 console . log ( "Posting new summary comment" ) ;
91- const body = getSummaryMessage ( { context, jobId, summary } ) ;
114+ const body = getCommentMessage ( { context, jobId, noModify , summary } ) ;
92115 return github . rest . issues . createComment ( {
93116 issue_number : issueNumber ,
94117 owner,
0 commit comments