Skip to content

Ignore running under copilot-setup-steps.yml or the 'copilot' env #1331

Description

@sommmen

As of Nerdbank.GitVersioning v3.9, the git engine is automatically disabled when running under GitHub Copilot, eliminating the need for manual configuration in most cases.

I just migrated today hoping this would work oob, but it seems to fail for me, copilot-setup-steps.yml
I'm thinking i the copilot-configuration-steps.yml does not run under the copilot 'actor' all the time?

I'd like to skip version generation when using copilot-setup-steps.yml or the 'copilot' env, the workflow is also used to run via trigger and this would cause the git versioning to fail due to the shallow fetch.

Right now with this issue github copilot works fine, but pr's editing the setup steps workflow file now fail. I've defined path triggers to make sure to validate the steps - i'd like to keep that functionality.

name: "Copilot Setup Steps"

# Automatically run the setup steps when they are changed to allow for easy validation, and
# allow manual testing through the repository's "Actions" tab
on:
  workflow_dispatch:
  push:
    paths:
      - .github/workflows/copilot-setup-steps.yml
  pull_request:
    paths:
      - .github/workflows/copilot-setup-steps.yml

jobs:
  # The job MUST be called `copilot-setup-steps` or it will not be picked up by Copilot.
  copilot-setup-steps:
    runs-on: ubuntu-latest

    # Set the permissions to the lowest permissions possible needed for your steps.
    # Copilot will be given its own token for its operations.
    permissions:
      # If you want to clone the repository as part of your setup steps, for example to install dependencies, you'll need the `contents: read` permission. If you don't clone the repository in your setup steps, Copilot will do this for you automatically after the steps complete.
      contents: read

    environment:
          name: copilot

    # You can define any steps you want, and they will run before the agent starts.
    # If you do not check out your code, Copilot will do this for you.
    steps:
    - uses: actions/checkout@v6
      with:
        fetch-depth: 2 # NOTE copilot env hard overrides this to 2, this is done only for clarity. Check the copilot docs.

    - name: Setup .NET
      uses: actions/setup-dotnet@v5
      with:
        dotnet-version: 9.x

    - name: Configure NuGet source
      run: |
        [redacted]
      
    - name: Restore .NET dependencies
      run: dotnet restore
      working-directory: src/back-end

    - name: Restore tools
      run: dotnet tool restore
      working-directory: src/back-end

    # saves cycles when adding migration
    - name: Restore tools (webapi)
      run: dotnet tool restore
      working-directory: src/back-end/WebApi

    - name: Build all SourceGenerators projects
      run: |
        for proj in $(find src/back-end/SourceGenerators -name '*.csproj'); do
          echo "Building $proj"
          dotnet build "$proj"
        done

    # Ubuntu patch see: https://github.com/SixLabors/Fonts/discussions/346
    - name: Patch ubuntu font
      run: |
        sudo rm -f /usr/share/fonts/truetype/noto/NotoColorEmoji.ttf && \
        sudo curl -sS -L -o /usr/share/fonts/truetype/noto/NotoColorEmoji-Regular.ttf \
        https://fonts.gstatic.com/s/notocoloremoji/v25/Yq6P-KqIXTD0t4D9z1ESnKM3-HpFab5s79iz64w.ttf
      
    - name: Setup pnpm
      uses: pnpm/action-setup@v4
      with:
        version: latest

    - name: Setup Node.js
      uses: actions/setup-node@v6
      with:
        node-version: '22'
        cache: 'pnpm'
        cache-dependency-path: src/front-end/pnpm-lock.yaml

    - name: Install Angular CLI
      run: pnpm add -g @angular/cli@19

    - name: Restore dependencies
      run: pnpm install --frozen-lockfile
      working-directory: src/front-end
Run for proj in $(find src/back-end/SourceGenerators -name '*.csproj'); do
Building src/back-end/SourceGenerators/[redacted].csproj
  Determining projects to restore...
  All projects are up-to-date for restore.
/home/runner/.nuget/packages/nerdbank.gitversioning/3.9.50/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: The "Nerdbank.GitVersioning.Tasks.GetBuildVersion" task failed unexpectedly. [/home/runner/.nuget/packages/nerdbank.gitversioning/3.9.50/build/PrivateP2PCaching.proj]
/home/runner/.nuget/packages/nerdbank.gitversioning/3.9.50/build/Nerdbank.GitVersioning.Inner.targets(17,5): error MSB4018: Nerdbank.GitVersioning.GitException: Shallow clone lacks the objects required to calculate version height. Use full clones or clones with a history at least as deep as the last version height resetting change. [/home/runner/.nuget/packages/nerdbank.gitversioning/3.9.50/build/PrivateP2PCaching.proj]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions