MCPcopy Create free account
hub / github.com/github/gh-aw / main

Function main

actions/setup/js/update_release.cjs:76–156  ·  view source on GitHub ↗

* Create a handler for update-release messages * This is the factory function called by the handler manager * * @param {Object} config - Handler configuration * @param {number} [config.max] - Maximum number of releases to update * @param {boolean} [config.footer] - Controls whether AI-generated

(config = {})

Source from the content-addressed store, hash-verified

74 * @returns {Promise<Function>} Handler function that processes a single message
75 */
76async function main(config = {}) {
77 const isStaged = isStagedMode(config);
78 const workflowName = process.env.GH_AW_WORKFLOW_NAME || "GitHub Agentic Workflow";
79 const includeFooter = parseBoolTemplatable(config.footer, true);
80 const githubClient = await createAuthenticatedGitHubClient(config);
81
82 /**
83 * Process a single update-release message
84 * @param {Object} message - The update-release message
85 * @param {Object} resolvedTemporaryIds - Map of resolved temporary IDs
86 * @returns {Promise<Object>} Result with release info
87 */
88 return async function handleUpdateRelease(message, resolvedTemporaryIds = {}) {
89 if (isStaged) {
90 logStagedPreviewInfo(`Would update release with tag ${message.tag || "(inferred)"}`);
91 return { skipped: true, reason: "staged_mode" };
92 }
93
94 core.info(`Processing update-release message`);
95
96 try {
97 const messageTag = typeof message.tag === "string" ? message.tag.trim() : message.tag;
98 const releaseTag = messageTag || (await inferReleaseTag(context, githubClient));
99
100 if (!releaseTag) {
101 throw new Error(`${ERR_CONFIG}: Release tag is required but not provided and cannot be inferred from event context`);
102 }
103
104 core.info(`Fetching release with tag: ${releaseTag}`);
105 const { data: release } = await githubClient.rest.repos.getReleaseByTag({
106 owner: context.repo.owner,
107 repo: context.repo.repo,
108 tag: releaseTag,
109 });
110
111 core.info(`Found release: ${release.name || release.tag_name} (ID: ${release.id})`);
112
113 const runUrl = buildWorkflowRunUrl(context, context.repo);
114 const workflowId = process.env.GH_AW_WORKFLOW_ID || "";
115
116 const newBody = updateBody({
117 currentBody: release.body ?? "",
118 newContent: message.body,
119 operation: message.operation || "append",
120 workflowName,
121 runUrl,
122 workflowId,
123 includeFooter,
124 });
125
126 const { data: updatedRelease } = await githubClient.rest.repos.updateRelease({
127 owner: context.repo.owner,
128 repo: context.repo.repo,
129 release_id: release.id,
130 body: newBody,
131 });
132
133 core.info(`Successfully updated release: ${updatedRelease.html_url}`);

Callers

nothing calls this directly

Calls 8

isStagedModeFunction · 0.85
parseBoolTemplatableFunction · 0.85
logStagedPreviewInfoFunction · 0.85
inferReleaseTagFunction · 0.85
buildWorkflowRunUrlFunction · 0.85
updateBodyFunction · 0.85
getErrorMessageFunction · 0.70

Tested by

no test coverage detected