-
Notifications
You must be signed in to change notification settings - Fork 2
chore: sync workflow templates #644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -980,13 +980,16 @@ async function createIssueCommentWithRetry({ github, owner, repo, issueNumber, b | |||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function buildSourceContextResolvedCommentBody(prNumber, sourceContext) { | ||||||||||||||||||
| const isIssueBacked = sourceContext?.requiresIssue || sourceContext?.issueNumber || sourceContext?.sourceType === SOURCE_TYPES.GITHUB_ISSUE; | ||||||||||||||||||
| return [ | ||||||||||||||||||
| '<!-- missing-issue-warning -->', | ||||||||||||||||||
| '### Workflow source detected', | ||||||||||||||||||
| '', | ||||||||||||||||||
| `PR #${prNumber} now has valid workflow source context (${formatSourceContextForLog(sourceContext)}).`, | ||||||||||||||||||
| '', | ||||||||||||||||||
| 'No linked GitHub issue is required for this PR.', | ||||||||||||||||||
| isIssueBacked | ||||||||||||||||||
| ? 'A linked GitHub issue is present for this PR.' | ||||||||||||||||||
| : 'No linked GitHub issue is required for this PR.', | ||||||||||||||||||
| ].join('\n'); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
@@ -1023,6 +1026,37 @@ function resolveExplicitNonIssueWorkflowSourceContext(pr = {}) { | |||||||||||||||||
| }; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function extractExplicitIssueSyncNumbers(pr = {}) { | ||||||||||||||||||
| const text = `${pr.title || ''}\n${pr.body || ''}`; | ||||||||||||||||||
| const issueNumbers = new Set(); | ||||||||||||||||||
| const patterns = [ | ||||||||||||||||||
| /\b(?:close[sd]?|closing|fix(?:e[sd])?|fixing|resolve[sd]?|resolving|address(?:e[sd])?|addressing)\s*[:#-]?\s*#([0-9]+)\b/gi, | ||||||||||||||||||
| /\b(?:(?:relate[sd]?\s+to|refs?|references?)\s+(?:issue\s+)?|(?:source|github|linked)\s+issue\s*)[:#-]?\s*#([0-9]+)\b/gi, | ||||||||||||||||||
| ]; | ||||||||||||||||||
| for (const pattern of patterns) { | ||||||||||||||||||
| for (const match of text.matchAll(pattern)) { | ||||||||||||||||||
| issueNumbers.add(Number(match[1])); | ||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
| return issueNumbers; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function hasExplicitIssueSyncReference(pr = {}) { | ||||||||||||||||||
| return extractExplicitIssueSyncNumbers(pr).size > 0; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| function resolveNonIssueWorkflowSourceContextForBodySync(pr = {}, issueNumber = null) { | ||||||||||||||||||
| const explicitNonIssueSourceContext = resolveExplicitNonIssueWorkflowSourceContext(pr); | ||||||||||||||||||
| if (!explicitNonIssueSourceContext) { | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
| const explicitIssueNumbers = extractExplicitIssueSyncNumbers(pr); | ||||||||||||||||||
| if (issueNumber && explicitIssueNumbers.has(Number(issueNumber))) { | ||||||||||||||||||
| return null; | ||||||||||||||||||
| } | ||||||||||||||||||
| return explicitNonIssueSourceContext; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| async function resolveSourceContextRepairComment({ | ||||||||||||||||||
| github, | ||||||||||||||||||
| owner, | ||||||||||||||||||
|
|
@@ -1356,7 +1390,9 @@ async function run({github: rawGithub, context, core, inputs}) { | |||||||||||||||||
| return; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const explicitNonIssueSourceContext = resolveExplicitNonIssueWorkflowSourceContext(pr); | ||||||||||||||||||
| const issueNumber = extractIssueNumberFromPull(pr); | ||||||||||||||||||
| const sourceContext = resolvePrSourceContext(pr); | ||||||||||||||||||
|
||||||||||||||||||
| const sourceContext = resolvePrSourceContext(pr); | |
| const sourceContext = resolvePrSourceContext(pr); | |
| if (sourceContext && sourceContext.noAutomation) { | |
| core.info( | |
| `PR #${pr.number} has workflow no-automation enabled (${formatSourceContextForLog(sourceContext)}); skipping PR metadata automation.`, | |
| ); | |
| return; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sourceContext.noAutomationis checked only after the workflow has already added/validated the instruction + lock reactions. Ifworkflow:no-automationis meant to avoid automation side-effects, consider short-circuiting earlier (right afterresolvePrSourceContext) so the workflow doesn't mutate comment reactions before skipping dispatch.