Skip to content
Closed
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
3 changes: 3 additions & 0 deletions .github/workflows/agentics-maintenance.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
44 changes: 44 additions & 0 deletions actions/setup/js/check_workflow_recompile_needed.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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");

/**
Expand Down Expand Up @@ -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) {
Expand Down
3 changes: 3 additions & 0 deletions pkg/workflow/maintenance_workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down