-
Notifications
You must be signed in to change notification settings - Fork 249
feat: add activation-comments to disable activation/fallback bot comments
#17834
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
422ce9b
8e22d15
8a36a07
a4f7607
93f6e0d
b49182a
d1536e5
946ee07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,8 @@ const { getErrorMessage } = require("./error_helpers.cjs"); | |
| const { generateWorkflowIdMarker } = require("./generate_footer.cjs"); | ||
| const { sanitizeContent } = require("./sanitize_content.cjs"); | ||
| const { ERR_NOT_FOUND, ERR_VALIDATION } = require("./error_codes.cjs"); | ||
| const { getMessages } = require("./messages_core.cjs"); | ||
| const { parseBoolTemplatable } = require("./templatable.cjs"); | ||
|
|
||
| /** | ||
| * Event type descriptions for comment messages | ||
|
|
@@ -60,6 +62,13 @@ function setCommentOutputs(commentId, commentUrl) { | |
| * Use add_reaction.cjs in the pre-activation job to add reactions first for immediate feedback. | ||
| */ | ||
| async function main() { | ||
| // Check if activation comments are disabled | ||
| const messagesConfig = getMessages(); | ||
| if (!parseBoolTemplatable(messagesConfig?.activationComments, true)) { | ||
| core.info("activation-comments is disabled: skipping activation comment creation"); | ||
| return; | ||
| } | ||
|
Comment on lines
+65
to
+70
|
||
|
|
||
| const runId = context.runId; | ||
| const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com"; | ||
| const runUrl = context.payload.repository ? `${context.payload.repository.html_url}/actions/runs/${runId}` : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -43,6 +43,8 @@ function generateXMLMarker(workflowName, runUrl) { | |
| const engineVersion = process.env.GH_AW_ENGINE_VERSION || ""; | ||
| const engineModel = process.env.GH_AW_ENGINE_MODEL || ""; | ||
| const trackerId = process.env.GH_AW_TRACKER_ID || ""; | ||
| const runId = process.env.GITHUB_RUN_ID || ""; | ||
| const workflowId = process.env.GH_AW_WORKFLOW_ID || ""; | ||
|
|
||
| // Build the key-value pairs for the marker | ||
| const parts = []; | ||
|
|
@@ -70,6 +72,16 @@ function generateXMLMarker(workflowName, runUrl) { | |
| parts.push(`model: ${engineModel}`); | ||
| } | ||
|
|
||
| // Add numeric run ID if available | ||
| if (runId) { | ||
| parts.push(`id: ${runId}`); | ||
| } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding |
||
|
|
||
| // Add workflow identifier if available | ||
| if (workflowId) { | ||
| parts.push(`workflow_id: ${workflowId}`); | ||
| } | ||
|
|
||
| // Always include run URL | ||
| parts.push(`run: ${runUrl}`); | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ const { getMessages } = require("./messages_core.cjs"); | |
| const { getErrorMessage, isLockedError } = require("./error_helpers.cjs"); | ||
| const { sanitizeContent } = require("./sanitize_content.cjs"); | ||
| const { ERR_VALIDATION } = require("./error_codes.cjs"); | ||
| const { parseBoolTemplatable } = require("./templatable.cjs"); | ||
|
|
||
| /** | ||
| * Collect generated asset URLs from safe output jobs | ||
|
|
@@ -60,6 +61,12 @@ async function main() { | |
| const messagesConfig = getMessages(); | ||
| const appendOnlyComments = messagesConfig?.appendOnlyComments === true; | ||
|
|
||
| // If activation comments are disabled entirely, skip all comment updates | ||
| if (!parseBoolTemplatable(messagesConfig?.activationComments, true)) { | ||
| core.info("activation-comments is disabled: skipping completion comment update"); | ||
| return; | ||
| } | ||
|
Comment on lines
+64
to
+68
|
||
|
|
||
| core.info(`Comment ID: ${commentId}`); | ||
| core.info(`Comment Repo: ${commentRepo}`); | ||
| core.info(`Run URL: ${runUrl}`); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,20 @@ | |
| const { getErrorMessage } = require("./error_helpers.cjs"); | ||
| const { getMessages } = require("./messages_core.cjs"); | ||
| const { sanitizeContent } = require("./sanitize_content.cjs"); | ||
| const { getPullRequestCreatedMessage, getIssueCreatedMessage, getCommitPushedMessage } = require("./messages_run_status.cjs"); | ||
| const { parseBoolTemplatable } = require("./templatable.cjs"); | ||
| const { generateXMLMarker } = require("./generate_footer.cjs"); | ||
|
|
||
| /** | ||
| * Build the workflow run URL from context and environment. | ||
| * @param {any} context - GitHub Actions context | ||
| * @returns {string} The workflow run URL | ||
| */ | ||
| function getRunUrl(context) { | ||
| const runId = context.runId || process.env.GITHUB_RUN_ID || ""; | ||
| const githubServer = process.env.GITHUB_SERVER_URL || "https://github.com"; | ||
| return context.payload?.repository?.html_url ? `${context.payload.repository.html_url}/actions/runs/${runId}` : `${githubServer}/${context.repo.owner}/${context.repo.repo}/actions/runs/${runId}`; | ||
| } | ||
|
|
||
| /** | ||
| * Update the activation comment with a link to the created pull request or issue | ||
|
|
@@ -16,7 +30,10 @@ const { sanitizeContent } = require("./sanitize_content.cjs"); | |
| */ | ||
| async function updateActivationComment(github, context, core, itemUrl, itemNumber, itemType = "pull_request") { | ||
| const itemLabel = itemType === "issue" ? "issue" : "pull request"; | ||
| const linkMessage = itemType === "issue" ? `\n\n✅ Issue created: [#${itemNumber}](${itemUrl})` : `\n\n✅ Pull request created: [#${itemNumber}](${itemUrl})`; | ||
| const workflowName = process.env.GH_AW_WORKFLOW_NAME || "Workflow"; | ||
| const runUrl = getRunUrl(context); | ||
| const body = itemType === "issue" ? getIssueCreatedMessage({ itemNumber, itemUrl }) : getPullRequestCreatedMessage({ itemNumber, itemUrl }); | ||
| const linkMessage = `\n\n${body}\n\n${generateXMLMarker(workflowName, runUrl)}`; | ||
| await updateActivationCommentWithMessage(github, context, core, linkMessage, itemLabel, { targetIssueNumber: itemNumber }); | ||
| } | ||
|
|
||
|
|
@@ -32,7 +49,9 @@ async function updateActivationComment(github, context, core, itemUrl, itemNumbe | |
| */ | ||
| async function updateActivationCommentWithCommit(github, context, core, commitSha, commitUrl, options = {}) { | ||
| const shortSha = commitSha.substring(0, 7); | ||
| const message = `\n\n✅ Commit pushed: [\`${shortSha}\`](${commitUrl})`; | ||
| const workflowName = process.env.GH_AW_WORKFLOW_NAME || "Workflow"; | ||
| const runUrl = getRunUrl(context); | ||
| const message = `\n\n${getCommitPushedMessage({ commitSha, shortSha, commitUrl })}\n\n${generateXMLMarker(workflowName, runUrl)}`; | ||
| await updateActivationCommentWithMessage(github, context, core, message, "commit", options); | ||
| } | ||
|
|
||
|
|
@@ -54,6 +73,12 @@ async function updateActivationCommentWithMessage(github, context, core, message | |
| const messagesConfig = getMessages(); | ||
| const appendOnlyComments = messagesConfig?.appendOnlyComments === true; | ||
|
|
||
| // Check if activation comments are disabled entirely | ||
| if (!parseBoolTemplatable(messagesConfig?.activationComments, true)) { | ||
| core.info("activation-comments is disabled: skipping activation comment update"); | ||
| return; | ||
| } | ||
|
Comment on lines
+76
to
+80
|
||
|
|
||
| // Parse comment repo (format: "owner/repo") with validation | ||
| let repoOwner = context.repo.owner; | ||
| let repoName = context.repo.repo; | ||
|
|
||
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.
Good guard: checking
activationCommentsbefore proceeding keeps the early-exit clean. Consider logging the config value at debug level to aid troubleshooting whenactivation-commentsis unexpectedly disabled.