Skip to content
This repository was archived by the owner on Feb 7, 2026. It is now read-only.

Add AI Copilot automation workflow with Workspace links and Chat reviews#4

Draft
Copilot wants to merge 4 commits into
mainfrom
copilot/open-copilot-workspace
Draft

Add AI Copilot automation workflow with Workspace links and Chat reviews#4
Copilot wants to merge 4 commits into
mainfrom
copilot/open-copilot-workspace

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 24, 2025

Implements zero-config automation that posts Copilot Workspace links and Chat-powered reviews on every issue/PR, with optional agent assignment for autonomous code generation.

Changes

Workflow (.github/workflows/ai-copilot-full.yml)

  • Triggers on issue/PR events (opened, edited, synchronize, reopened)
  • Auto-assigns @copilot when task keywords detected (fix, implement, add, update, bug, feature, create, build)
  • Generates contextual Workspace URLs: copilot-workspace.githubnext.com/{owner}/{repo}?task={context}
  • Calls Copilot Chat API with graceful fallback to generic message
  • Posts unified comment with review + Workspace link + agent status
  • RFC 6750 compliant Bearer auth, fetch via globalThis.fetch polyfill

Custom Agent (.github/agents/copilot-automation-manager.agent.md)

  • Expert system for workflow monitoring, troubleshooting, and optimization
  • Handles API endpoint changes and configuration tuning

Documentation

  • Setup guide with prerequisites, examples, troubleshooting
  • Quick reference for commands and configuration
  • Flow diagrams showing execution timeline and component architecture

Example Output

When issue created with "Fix login bug":

🤖 AI Copilot Activated!

Chat Review:
[AI-generated analysis or fallback message]

Workspace Ready:
👉 Dive into Copilot Workspace - AI plans/writes code/PRs

Agent Status: 🚀 Running in background (check Actions tab for PR soon!)

Security

  • Zero vulnerabilities (CodeQL verified)
  • Repository-scoped GITHUB_TOKEN only
  • No credential exposure in logs
  • Graceful error handling prevents workflow failures

Testing

Create issue with "Add hello world feature" and verify automated comment appears within 60s with working Workspace link.

Original prompt

name: 🚀 Instant Copilot Workspace

on:
issues:
types: [opened]
pull_request:
types: [opened, synchronize]

permissions:
contents: read
issues: write
pull-requests: write

jobs:
open-copilot-workspace:
runs-on: ubuntu-latest
steps:
- name: 🤖 Open Copilot Workspace & Post Link
uses: actions/github-script@v7
with:
script: |
const event = github.context.payload;
let title, number, url;

        if (event.issue) {
          title = event.issue.title;
          number = event.issue.number;
          url = `${github.context.payload.repository.html_url}/issues/${number}`;
        } else {
          title = event.pull_request.title;
          number = event.pull_request.number;
          url = `${github.context.payload.repository.html_url}/pull/${number}`;
        }
        
        // This is the REAL Copilot Workspace direct link
        const workspaceUrl = `https://githubcopilotworkspace.github.com/?repo=${github.context.repo.owner}%2F${github.context.repo.repo}&ref=${github.context.sha}#${number || ''}`;
        
        const body = `🚀 **Copilot Workspace is ready!**\n\nOne-click AI session created for you:\n👉 [Open Copilot Workspace now](${workspaceUrl})\n\nCopilot can now write code, tests, docs, and even create PRs automatically. Just click the link above!`;
        
        if (event.issue) {
          await github.rest.issues.createComment({
            ...context.repo,
            issue_number: number,
            body
          });
        } else {
          await github.rest.pullRequests.createReview({
            ...context.repo,
            pull_number: number,
            body,
            event: 'COMMENT'
          });
        }
        
        console.log(`Copilot Workspace link posted: ${workspaceUrl}`);

name: 🤖 Auto Copilot Chat Reviews

on:
issues:
types: [opened, edited]
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read
issues: write
pull-requests: write
actions: write # For agent mode if assigning

jobs:
copilot-chat-review:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }} # Enables Copilot auth

  - name: 🤖 Trigger Copilot Chat Analysis & Post Review
    uses: actions/github-script@v7
    env:
      GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    with:
      script: |
        const event = github.context.payload;
        let title, body, number, isIssue = false;
        
        if (event.issue) {
          isIssue = true;
          title = event.issue.title;
          body = event.issue.body || '';
          number = event.issue.number;
        } else {
          title = event.pull_request.title;
          body = event.pull_request.body || '';
          number = event.pull_request.number;
        }
        
        console.log(`🤖 Analyzing: ${title}`);
        
        // Step 1: Auto-assign to @copilot if it's a task (triggers coding agent)
        const taskKeywords = ['fix', 'implement', 'add', 'update', 'bug', 'feature'];
        const isTask = taskKeywords.some(kw => body.toLowerCase().includes(kw));
        if (isIssue && isTask) {
          await github.rest.issues.addAssignees({
            ...context.repo,
            issue_number: number,
            assignees: ['copilot']  // Triggers autonomous agent mode
          });
          console.log('👀 Assigned to @copilot - Agent starting in background...');
        }
        
        // Step 2: Generate Copilot Chat response (via internal endpoints - auth via token)
        // Fetch token for Copilot Chat
        const tokenResponse = await fetch('https://github.com/github-copilot/chat/token', {
          headers: { Authorization: `bearer ${process.env.GITHUB_TOKEN}` }
        });
        const { access_token: copilotToken } = await tokenResponse.json();
        
        // Create new chat thread with context
        const threadResponse = await fetch('https://api.githubcopilot.com/chat/conversations', {
          method: 'POST',
          headers: {
            Authorization: `bearer ${copilotToken}`,
            'Content-Type': 'application/json'
          },
          body: JSON.stringify({
            title: `Auto-review: ${title}`,
            messages: [{
              role: 'user',
              content: `Review this ${isIssue ? 'issue' : 'PR'}: Title: ${title}\nBody: ${body}\n\nRepo context: ${github.context.repo.owner}/${github.context.repo.repo} at ${github.context.sha}\n\nProvide: summary, suggestions, code fixes/tests if needed, potent...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI self-assigned this Nov 24, 2025
Copilot AI and others added 3 commits November 24, 2025 07:06
Co-authored-by: issdandavis <215328633+issdandavis@users.noreply.github.com>
Co-authored-by: issdandavis <215328633+issdandavis@users.noreply.github.com>
Co-authored-by: issdandavis <215328633+issdandavis@users.noreply.github.com>
Copilot AI changed the title [WIP] Add instant Copilot workspace opening feature Add AI Copilot automation workflow with Workspace links and Chat reviews Nov 24, 2025
Copilot AI requested a review from issdandavis November 24, 2025 07:16
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants