Skip to content

GitHub Actions failed to execute command 'git' for dotnet project that works locally? #137

@ptr727

Description

@ptr727

Version

0.7.2

Details

Pre-commit hooks work fine locally
I can run dotnet husky run locally for testing.
I added a dotnet husky run as part of my github actions test steps.
When I test the action locally using Nektos ACT it works fine.

When my action runs on github I get this error:

4s
Run dotnet tool restore
  dotnet tool restore
  dotnet husky run
  shell: /usr/bin/bash -e {0}
  env:
    DOTNET_ROOT: /usr/share/dotnet
Tool 'csharpier' (version '1.0.3') was restored. Available commands: csharpier
Tool 'husky' (version '0.7.2') was restored. Available commands: husky

Restore was successful.
[Husky] 🚀 Loading tasks ...
failed to execute command 'git'
Could not find Husky path
Error: Process completed with exit code 1.

I found an issue with similar error, but this prjoctect has only 1 root and is in the root.

Any ideas what I'm doing wrong?

task runner:

{
    "$schema": "https://alirezanet.github.io/Husky.Net/schema.json",
    "tasks": [
        {
            "name": "CSharpier Format",
            "command": "dotnet",
            "args": [
                "csharpier",
                "format",
                "--log-level=debug",
                "${staged}"
            ],
            "include": [
                "**/*.cs"
            ]
        },
        {
            "name": ".Net Format",
            "command": "dotnet",
            "args": [
                "format",
                "style",
                "--verify-no-changes",
                "--severity=info",
                "--verbosity=detailed",
                "--exclude-diagnostics=IDE0055"
            ],
            "include": [
                "**/*.cs"
            ]
        }
    ]
}

Github actions:

  test:
    name: Test
    runs-on: ubuntu-latest

    steps:

      # https://github.com/marketplace/actions/setup-net-core-sdk
      - name: Setup .NET SDK
        uses: actions/setup-dotnet@v4
        with:
          dotnet-version: "9.x"

      # https://github.com/marketplace/actions/checkout
      - name: Checkout code
        uses: actions/checkout@v4

     # Format checks
      - name: Format checks
        run: |
          dotnet tool restore
          dotnet husky run

        # https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test
      - name: Run unit tests
        run: dotnet test ./PlexCleanerTests/PlexCleanerTests.csproj

Steps to reproduce

  1. Run locally, ok
  2. Run locally in github actions, ok
  3. Run remote github actions, fail

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions