Interview Prep/GitHub Actions/Contexts, Expressions, Env & Outputs

How does `hashFiles` work and where can it be used?

IntermediateConceptContexts, Expressions, Env & Outputs
Answer

hashFiles('**/package-lock.json') returns a SHA-256 hash of all matching files under GITHUB_WORKSPACE (sorted, then combined), or an empty string if nothing matches. Multiple patterns and negation are allowed: hashFiles('**/go.sum', '!vendor/**'). It is evaluated on the runner, so it works in step-level keys like a cache key, not in job-level if or runs-on. It must finish within a time limit, so avoid patterns that scan node_modules in a huge workspace.

All GitHub Actions questions Roadmap: GitHub Actions

More on Contexts, Expressions, Env & Outputs