diff --git a/.github/workflows/agentics-maintenance.yml b/.github/workflows/agentics-maintenance.yml index 2bd8a884558..b980994e0d5 100644 --- a/.github/workflows/agentics-maintenance.yml +++ b/.github/workflows/agentics-maintenance.yml @@ -124,7 +124,10 @@ jobs: - name: Check for out-of-sync workflows and create issue if needed uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0 + env: + GH_AW_AGENT_TOKEN: ${{ secrets.GH_AW_AGENT_TOKEN }} with: + github-token: ${{ secrets.GH_AW_AGENT_TOKEN || secrets.GITHUB_TOKEN }} script: | const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); setupGlobals(core, github, context, exec, io); diff --git a/actions/setup/js/check_workflow_recompile_needed.cjs b/actions/setup/js/check_workflow_recompile_needed.cjs index d605527b887..a1ac65874f2 100644 --- a/actions/setup/js/check_workflow_recompile_needed.cjs +++ b/actions/setup/js/check_workflow_recompile_needed.cjs @@ -3,6 +3,7 @@ const { getErrorMessage } = require("./error_helpers.cjs"); const { generateFooterWithMessages, getFooterWorkflowRecompileMessage, getFooterWorkflowRecompileCommentMessage, generateXMLMarker } = require("./messages_footer.cjs"); +const { findAgent, getIssueDetails, assignAgentToIssue } = require("./assign_agent_helpers.cjs"); const fs = require("fs"); /** @@ -170,6 +171,49 @@ async function main() { core.info(`✓ Created issue #${newIssue.data.number}: ${newIssue.data.html_url}`); + // Check if GH_AW_AGENT_TOKEN is available to assign copilot + const agentToken = process.env.GH_AW_AGENT_TOKEN; + if (agentToken && agentToken.trim()) { + core.info("GH_AW_AGENT_TOKEN is available, attempting to assign issue to @copilot"); + + try { + const agentName = "copilot"; + + // Find copilot agent + core.info(`Looking for ${agentName} coding agent...`); + const agentId = await findAgent(owner, repo, agentName); + + if (!agentId) { + core.warning(`${agentName} coding agent is not available for this repository - skipping assignment`); + } else { + core.info(`Found ${agentName} coding agent (ID: ${agentId})`); + + // Get issue details + core.info(`Getting details for issue #${newIssue.data.number}...`); + const issueDetails = await getIssueDetails(owner, repo, newIssue.data.number); + + if (!issueDetails) { + core.warning("Failed to get issue details - skipping assignment"); + } else { + // Assign copilot to the issue + core.info(`Assigning ${agentName} coding agent to issue #${newIssue.data.number}...`); + const success = await assignAgentToIssue(issueDetails.issueId, agentId, issueDetails.currentAssignees, agentName, null); + + if (success) { + core.info(`✓ Successfully assigned ${agentName} coding agent to issue #${newIssue.data.number}`); + } else { + core.warning(`Failed to assign ${agentName} via GraphQL`); + } + } + } + } catch (assignError) { + core.warning(`Failed to assign copilot to issue: ${getErrorMessage(assignError)}`); + core.info("Issue was created successfully, but copilot assignment failed - continuing"); + } + } else { + core.info("GH_AW_AGENT_TOKEN is not available - skipping copilot assignment"); + } + // Write to job summary await core.summary.addHeading("Workflow Recompilation Needed", 2).addRaw(`Created issue [#${newIssue.data.number}](${newIssue.data.html_url}) to track workflow recompilation.`).write(); } catch (error) { diff --git a/pkg/workflow/maintenance_workflow.go b/pkg/workflow/maintenance_workflow.go index a8fce3e4524..b7dd23aea85 100644 --- a/pkg/workflow/maintenance_workflow.go +++ b/pkg/workflow/maintenance_workflow.go @@ -254,7 +254,10 @@ jobs: - name: Check for out-of-sync workflows and create issue if needed uses: ` + GetActionPin("actions/github-script") + ` + env: + GH_AW_AGENT_TOKEN: ${{ secrets.GH_AW_AGENT_TOKEN }} with: + github-token: ${{ secrets.GH_AW_AGENT_TOKEN || secrets.GITHUB_TOKEN }} script: | const { setupGlobals } = require('/opt/gh-aw/actions/setup_globals.cjs'); setupGlobals(core, github, context, exec, io);