Git & GitHub Interview Question #149

How would you investigate when a GitHub Actions workflow passes locally but fails in CI?

Security, Team Workflows, Troubleshooting & Senior Git/GitHub Scenarios Senior Advanced

Quick Interview Answer

Compare the CI environment with the local environment systematically. Check operating system, runtime and SDK versions, environment variables, working directory, file-name casing, line endings, dependency versions, network access, permissions, secrets, and commands used by the workflow.

Detailed Explanation

Compare the CI environment with the local environment systematically. Check operating system, runtime and SDK versions, environment variables, working directory, file-name casing, line endings, dependency versions, network access, permissions, secrets, and commands used by the workflow.

Reproduce the exact CI commands locally where possible and inspect the failing job logs rather than guessing. Pin required tool versions, use deterministic dependency files, avoid relying on machine-specific state, and add diagnostics that do not expose secrets.

For .NET projects, verify the SDK selected by the workflow, solution or project path, configuration, test dependencies, and any platform-specific behavior.

Code Example

# Compare local environment
dotnet --info
dotnet restore
dotnet build --configuration Release
dotnet test --configuration Release

# Inspect workflow definitions
git grep "dotnet-version" .github/workflows
git grep "dotnet build" .github/workflows