Skip to content

CICD-102 · Cache pip downloads by lock digest ​

Encyclopedia · Workflow reuse and caching · All snippets

Previous · CICD-101 · Next · CICD-103

1. Where it fits ​

  • Placement .github/workflows/ci.yml, under a job's steps.
  • Prerequisites trusted checkout and cache/artifact support verified on the chosen Actions runner.
  • Platforms github-actions.

2. Copy the snippet ​

yaml
uses: actions/cache@v4
with:
  path: ~/.cache/pip
  key: "pip-${{ runner.os }}-${{ hashFiles('requirements.txt') }}"

3. How it works ​

This invokes an action at step scope or a reusable workflow at job scope. The reference and declared inputs must match that contract.

4. Verify the result ​

Hash the dependency input and verify second-run cache hit.

Validation syntax-validated (YAML parse). Status definitions.