Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 20, 2025

This PR adds a new GitHub Actions workflow file to preconfigure Copilot's environment before the agent starts, following the GitHub Copilot Agents documentation best practices. Additionally, it creates a comprehensive reusable .NET setup action and updates all existing workflows to use it for consistency and maintainability.

What's Added

.github/workflows/copilot-setup-steps.yml

  • Single job named copilot-setup-steps with minimal permissions (contents: read)
  • Automatic triggers on workflow file changes (push/PR events) and manual dispatch
  • Consistent with existing CI workflows using the same action versions and patterns

.github/actions/setup-dotnet/action.yml

  • Comprehensive reusable action for .NET environment setup across all workflows
  • Automatically runs dotnet restore and includes optional build parameter
  • Uses global.json exclusively for consistent .NET SDK version management
  • Includes NuGet package caching for performance optimization

Updated Existing Workflows

  • build-and-test.yml: Now uses reusable action with build: 'true' parameter
  • Code-Analysis.yml: Now uses reusable action for setup and restore

Environment Setup Steps

  1. Code Checkout: Uses actions/checkout@v5 (consistent with existing workflows)
  2. .NET Environment: Uses the new reusable setup-dotnet action with automatic restore
  3. Optional Build: Configurable build step for workflows that require compilation

Design Decisions

  • Removed Node.js Components: Eliminated unnecessary Node.js setup and npm dependencies since this is a pure .NET C# project with no JavaScript code
  • Consolidated .NET Setup: Created a single reusable action that eliminates ~45 lines of duplicated setup code across workflows
  • Global.json Only: Simplified to use only global.json for .NET version management across all workflows
  • Automatic Restore: All workflows now get dependency restoration automatically
  • Minimal Permissions: Only requests necessary contents: read permission for security
  • Path-based Triggers: Optimized to only run when the workflow file itself changes, plus manual dispatch

The changes result in cleaner, more maintainable workflows while ensuring Copilot agents have access to the necessary .NET tools and dependencies. All workflows now follow a consistent pattern for .NET environment setup.

Benefits

  • DRY Principle: Eliminated code duplication across workflows
  • Consistency: All workflows now use the same .NET setup approach
  • Maintainability: .NET setup changes only need to be made in one place
  • Simplified Workflows: Each workflow is now more focused on its specific purpose

Warning

http://crl3.digicert.com:443/sha2-assured-cs-g1.crl

  • Triggering command: dotnet restore (http block)

If you need me to access, download, or install something from one of these locations, you can either:

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, 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.

Additionally, ensure to include the correct permissions for the workflow file to function properly.

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, 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.

Additionally, ensure to include the correct permissions for the workflow file to function properly.


💡 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 do we need a package json and package lock? And where do we use node in this project? And can we have a reusable action to share the basic .net setup (install restore build) between the workflows?

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot do we need a package json and package lock? And where do we use node in this project? And can we have a reusable action to share the basic .net setup (install restore build) between the workf...

You're absolutely right on all three points:

  1. Package.json/package-lock.json: Removed - they were unnecessary since this is a pure .NET C# project with no JavaScript/TypeScript code.

  2. Node.js usage: None - I confirmed there are no JS/TS files in the repository, only .NET/C# code and JSON config files.

  3. Reusable action: Created .github/actions/setup-dotnet/action.yml that consolidates the common .NET setup patterns (SDK setup + NuGet caching) used across workflows. It supports both global.json and specific version configurations.

The workflow now focuses solely on .NET environment setup, which is what this project actually needs. Commit: b098362

Copilot AI changed the title Add GitHub Actions workflow for Copilot environment setup Add GitHub Actions workflow for Copilot environment setup with reusable .NET action Sep 20, 2025
@BenjaminMichaelis
Copy link
Member

@copilot could the setup .net action include build and restore as well? And just only ever use the global json since we have it? And should our main CI file also use this reusable action

Copy link
Contributor Author

Copilot AI commented Sep 20, 2025

@copilot could the setup .net action include build and restore as well? And just only ever use the global json since we have it? And should our main CI file also use this reusable action

Absolutely! Made all three improvements:

  1. Build and restore included: The setup action now automatically runs dotnet restore and has an optional build: 'true' parameter for workflows that need building.

  2. Global.json only: Simplified to always use global.json instead of specific versions, ensuring consistency across all workflows.

  3. Updated main CI workflows: Both build-and-test.yml and Code-Analysis.yml now use the reusable action, eliminating ~15 lines of duplicated setup code in each workflow.

The reusable action is now much more comprehensive and all workflows are cleaner and more maintainable. Commit: 49acef2

Copilot AI changed the title Add GitHub Actions workflow for Copilot environment setup with reusable .NET action Add GitHub Actions workflow for Copilot environment setup and consolidate .NET setup across all workflows Sep 20, 2025
@BenjaminMichaelis BenjaminMichaelis marked this pull request as ready for review September 20, 2025 09:23
Copilot AI review requested due to automatic review settings September 20, 2025 09:23
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds a new GitHub Actions workflow for Copilot environment setup and consolidates .NET setup configuration across all workflows using a reusable action. The changes remove Node.js components that weren't needed for this .NET-only project and create a consistent approach to .NET environment configuration.

Key changes:

  • New Copilot setup workflow that focuses on .NET environment rather than Node.js
  • Reusable .NET setup action that handles SDK setup, caching, restore, and optional build
  • Updated existing workflows to use the centralized setup action, eliminating code duplication

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
.github/workflows/copilot-setup-steps.yml New workflow for Copilot environment setup using .NET only
.github/workflows/build-and-test.yml Refactored to use reusable .NET setup action with build enabled
.github/workflows/Code-Analysis.yml Updated to use reusable .NET setup action without build step
.github/actions/setup-dotnet/action.yml New composite action consolidating .NET setup, caching, and restore logic

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@BenjaminMichaelis BenjaminMichaelis merged commit 615cbb9 into v12.0 Sep 20, 2025
7 checks passed
@BenjaminMichaelis BenjaminMichaelis deleted the copilot/fix-11d16f53-d3c4-4ff7-8b5a-30c6a14c15bb branch September 20, 2025 14:36
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