Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 20, 2025

This PR adds a new GitHub Actions workflow to preconfigure the environment before GitHub Copilot agents start working on the repository. The workflow follows best practices for Copilot integration and maintains consistency with existing CI/CD workflows.

Changes Made

New Workflow File

  • .github/workflows/copilot-setup-steps.yml - Main workflow that sets up .NET environment and builds the project for Copilot

Reusable Composite Action

  • .github/actions/setup-dotnet-build/action.yml - New reusable composite action that handles .NET setup, dependency restoration, and building
  • Updated build-and-test.yml - Now uses the reusable action to eliminate code duplication

Workflow Features

The new copilot-setup-steps job includes:

  1. Environment Setup: Configures .NET (versions 3.1.x, 6.x) consistent with existing build workflows
  2. Dependency Management: Restores .NET packages via dotnet restore
  3. Project Building: Builds the project so Copilot has access to compiled artifacts for better code analysis
  4. Security: Uses minimal permissions (contents: read only) following security best practices
  5. Triggers:
    • Automatically runs on changes to the workflow file itself (push/PR events)
    • Supports manual execution via workflow_dispatch

Consistency with Existing Workflows

The implementation maintains consistency with the repository's existing CI/CD patterns:

  • Uses the same shell (pwsh) and runner (ubuntu-latest)
  • Follows the same .NET version strategy as build-and-test.yml
  • Uses established action versions (actions/checkout@v5, actions/setup-dotnet@v4)
  • Maintains the same structural patterns and naming conventions
  • Introduces reusable actions to reduce duplication across workflows

This workflow ensures Copilot agents have access to a properly configured .NET development environment with compiled artifacts before beginning code analysis or generation tasks.

This pull request was created as a result of the following prompt from Copilot chat.

Create a new GitHub Actions workflow file to preconfigure Copilot's environment before the agent starts. The workflow file should be located at .github/workflows/copilot-setup-steps.yml and contain a single job named copilot-setup-steps. Follow the best practices outlined in the GitHub Copilot Agents documentation, ensuring the job uses minimal permissions required and reusable actions for consistency. Prefer modular reusable actions for repeatable tasks like setting up .NET or Node.js, as referenced in the existing build and test CI workflows, but avoid over-modularization. The workflow should use the same triggers as the example provided:

  • Automatically run on changes to .github/workflows/copilot-setup-steps.yml (push and pull request events)
  • Manual triggers via workflow_dispatch

The job should include the following steps:

  1. Check out the code using actions/checkout@v5.
  2. Set up Node.js using actions/setup-node@v4 with Node.js version 20 and npm caching.
  3. Install JavaScript dependencies using npm ci.
  4. Set up .NET environment, ensuring consistency with existing build and test CI workflows by using reusable actions where applicable.
  5. Include any other environment-specific setup steps required for Copilot to function effectively.

💡 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 changed the title [WIP] Create Copilot Setup Steps Workflow Add GitHub Actions workflow for Copilot environment setup Sep 20, 2025
@BenjaminMichaelis
Copy link
Member

@copilot i don't see node or in this project or the existing CI. Do we need this stuff?

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot i don't see node or in this project or the existing CI. Do we need this stuff?

You're absolutely correct! This is a pure .NET project and doesn't need Node.js. I removed the unnecessary Node.js setup, npm ci, and JavaScript dependency files. The workflow now only includes .NET environment setup (consistent with your existing CI workflows) plus basic Copilot environment configuration. Fixed in commit bafe2f1.

@BenjaminMichaelis
Copy link
Member

@copilot should we include building the project in the setup? And should the setup dotnet / restore / build be in a reusable action so it can be shared with the main CI workflow?

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot should we include building the project in the setup? And should the setup dotnet / restore / build be in a reusable action so it can be shared with the main CI workflow?

Great suggestions! I've made both changes:

  1. Added building to the setup - The Copilot workflow now builds the project so Copilot has access to compiled artifacts for better code understanding.

  2. Created reusable action - Added .github/actions/setup-dotnet-build/action.yml as a composite action that handles .NET setup, restore, and build. Updated both the Copilot workflow and build-and-test workflow to use it (deploy workflow kept separate due to custom version parameters).

This eliminates duplication and makes the workflows more maintainable. Changes in commit aeefe54.

Copilot AI changed the title Add GitHub Actions workflow for Copilot environment setup Add GitHub Actions workflow for Copilot environment setup with reusable .NET build action Sep 20, 2025
@BenjaminMichaelis BenjaminMichaelis marked this pull request as ready for review September 20, 2025 09:23
@BenjaminMichaelis BenjaminMichaelis merged commit 7c054d4 into main Sep 20, 2025
4 of 6 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the copilot/fix-6011a7cf-8761-458b-b66e-5603f268b051 branch September 20, 2025 09:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants