Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/agentic-campaign-generator.lock.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions .github/workflows/agentic-campaign-generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,31 +72,35 @@ safe-outputs:

Creating a tracking Project and generating campaign files + orchestrator workflow.

No action needed right now — the [{workflow_name}]({run_url}) will open a pull request and post the link + checklist back on this issue when ready.
No action needed — the [{workflow_name}]({run_url}) will open a pull request and post the link + checklist back on this issue when ready.

> To stop this run: remove the label that started it.
> Docs: https://githubnext.github.io/gh-aw/guides/campaigns/getting-started/"

> **Docs**: https://githubnext.github.io/gh-aw/guides/campaigns/getting-started/"
run-success: "### :white_check_mark: Campaign setup complete

Tracking Project created and pull request with generated campaign files is ready.

Next steps:
- Review + merge the PR
- Run the campaign from the Actions tab
**Next steps**: Review + merge the PR, then run the campaign from the Actions tab.

> Docs: https://githubnext.github.io/gh-aw/guides/campaigns/getting-started/"
> **Docs**: https://githubnext.github.io/gh-aw/guides/campaigns/getting-started/"
run-failure: "### :x: Campaign setup {status}

Common causes:
**Common causes**:

- `GH_AW_PROJECT_GITHUB_TOKEN` is missing or invalid

- Token lacks access to GitHub Projects

Action required:
**Action required**:

- Fix the first error in the logs

- Re-apply the label to re-run

> Troubleshooting: https://githubnext.github.io/gh-aw/guides/campaigns/flow/#when-something-goes-wrong
> Docs: https://githubnext.github.io/gh-aw/guides/campaigns/getting-started/"
> **Troubleshooting**: https://githubnext.github.io/gh-aw/guides/campaigns/flow/#when-something-goes-wrong

> **Docs**: https://githubnext.github.io/gh-aw/guides/campaigns/getting-started/"
timeout-minutes: 10
---

Expand Down
103 changes: 96 additions & 7 deletions actions/setup/js/update_activation_comment.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/// <reference types="@actions/github-script" />

const { getErrorMessage } = require("./error_helpers.cjs");
const { getMessages } = require("./messages_core.cjs");

/**
* Update the activation comment with a link to the created pull request or issue
Expand Down Expand Up @@ -44,13 +45,9 @@ async function updateActivationCommentWithMessage(github, context, core, message
const commentId = process.env.GH_AW_COMMENT_ID;
const commentRepo = process.env.GH_AW_COMMENT_REPO;

// If no comment was created in activation, skip updating
if (!commentId) {
core.info("No activation comment to update (GH_AW_COMMENT_ID not set)");
return;
}

core.info(`Updating activation comment ${commentId}`);
// Check if append-only-comments is enabled
const messagesConfig = getMessages();
const appendOnlyComments = messagesConfig?.appendOnlyComments === true;

// Parse comment repo (format: "owner/repo") with validation
let repoOwner = context.repo.owner;
Expand All @@ -65,6 +62,98 @@ async function updateActivationCommentWithMessage(github, context, core, message
}
}

// Append-only mode: create a new comment instead of updating the activation comment
if (appendOnlyComments) {
core.info("Append-only-comments enabled: creating a new comment");
try {
const eventName = context.eventName;

// Discussions: create a new discussion comment (threaded reply for discussion_comment)
if (eventName === "discussion" || eventName === "discussion_comment") {
const discussionNumber = context.payload?.discussion?.number;
if (!discussionNumber) {
core.warning("Unable to determine discussion number for append-only comment; skipping");
return;
}

const { repository } = await github.graphql(
`
query($owner: String!, $repo: String!, $num: Int!) {
repository(owner: $owner, name: $repo) {
discussion(number: $num) {
id
}
}
}`,
{ owner: repoOwner, repo: repoName, num: discussionNumber }
);

const discussionId = repository?.discussion?.id;
if (!discussionId) {
core.warning("Unable to resolve discussion id for append-only comment; skipping");
return;
}

const replyToId = eventName === "discussion_comment" ? context.payload?.comment?.node_id : null;
const mutation = replyToId
? `mutation($dId: ID!, $body: String!, $replyToId: ID!) {
addDiscussionComment(input: { discussionId: $dId, body: $body, replyToId: $replyToId }) {
comment { id url }
}
}`
: `mutation($dId: ID!, $body: String!) {
addDiscussionComment(input: { discussionId: $dId, body: $body }) {
comment { id url }
}
}`;

const variables = replyToId ? { dId: discussionId, body: message, replyToId } : { dId: discussionId, body: message };
const result = await github.graphql(mutation, variables);
const created = result?.addDiscussionComment?.comment;
const successMessage = label ? `Successfully created append-only discussion comment with ${label} link` : "Successfully created append-only discussion comment";
core.info(successMessage);
if (created?.id) core.info(`Comment ID: ${created.id}`);
if (created?.url) core.info(`Comment URL: ${created.url}`);
return;
}

// Issues/PRs: determine issue number from event payload and create a new issue comment
const issueNumber = context.payload?.issue?.number || context.payload?.pull_request?.number;
if (!issueNumber) {
core.warning("Unable to determine issue/PR number for append-only comment; skipping");
return;
}

const response = await github.request("POST /repos/{owner}/{repo}/issues/{issue_number}/comments", {
owner: repoOwner,
repo: repoName,
issue_number: issueNumber,
body: message,
headers: {
Accept: "application/vnd.github+json",
},
});

const successMessage = label ? `Successfully created append-only comment with ${label} link` : "Successfully created append-only comment";
core.info(successMessage);
if (response?.data?.id) core.info(`Comment ID: ${response.data.id}`);
if (response?.data?.html_url) core.info(`Comment URL: ${response.data.html_url}`);
return;
} catch (error) {
// Don't fail the workflow if we can't create the comment - just log a warning
core.warning(`Failed to create append-only comment: ${getErrorMessage(error)}`);
return;
}
}

// Standard mode: update the existing activation comment
// If no comment was created in activation, skip updating
if (!commentId) {
core.info("No activation comment to update (GH_AW_COMMENT_ID not set)");
return;
}

core.info(`Updating activation comment ${commentId}`);
core.info(`Updating comment in ${repoOwner}/${repoName}`);

// Check if this is a discussion comment (GraphQL node ID format)
Expand Down
Loading
Loading