The actions/cache action outputs a boolean variable named cache-hit . You can print this to verify if the restoration actually succeeded.
A known design behavior of the actions/cache action is that its "post" step, which compresses and saves the cache, will not run if any previous step in the job fails. For example, if your "Build" step fails, the "post" step for the cache is skipped, meaning that even if a later run fixes the build, it will have to start from scratch.
: Caching can be used to store the results of build and test actions, speeding up the feedback loop in CI/CD pipelines. debug-action-cache
You can pass these to a script that queries or even downloads cache metadata. Example debug step:
You do not add a new YAML step. Instead, you set a in your repository: The actions/cache action outputs a boolean variable named
- name: Cache Node Modules uses: actions/cache@v4 env: CACHE_DEBUG: true with: path: node_modules key: $ runner.os -node-$ hashFiles('package-lock.json')
The first line of defense is . GitHub Actions supports two environment variables that unlock detailed logs: For example, if your "Build" step fails, the
| Problem | Likely cause | Debug check | |--------|--------------|--------------| | Cache miss every run | Key includes github.sha or github.run_id | Log the key — is it changing? | | Cache saved every run | Key too specific + no restore-keys | Add a broader restore-keys | | Cache too large (>10 GB) | Unnecessary files | List cached dir content in debug mode | | Cache not restored on pull_request | Different branch base | Use restore-keys without branch hash |
step to output detailed logs, including the internal API calls used to check for existing cache versions. GitHub Docs 2. Inspecting Cache States via the UI