mirror of
https://code.forgejo.org/actions/cache.git
synced 2025-04-21 16:23:56 +08:00
Add Python example using 'pip cache dir' to get cache location
This commit is contained in:
parent
e3aaca2f93
commit
eb479c07a5
1 changed files with 20 additions and 0 deletions
20
examples.md
20
examples.md
|
@ -18,6 +18,7 @@
|
|||
- [Python - pip](#python---pip)
|
||||
- [Simple example](#simple-example)
|
||||
- [Multiple OS's in a workflow](#multiple-oss-in-a-workflow)
|
||||
- [Using pip to get cache location](#using-pip-to-get-cache-location)
|
||||
- [Using a script to get cache location](#using-a-script-to-get-cache-location)
|
||||
- [R - renv](#r---renv)
|
||||
- [Simple example](#simple-example-1)
|
||||
|
@ -290,6 +291,25 @@ Replace `~/.cache/pip` with the correct `path` if not using Ubuntu.
|
|||
${{ runner.os }}-pip-
|
||||
```
|
||||
|
||||
### Using pip to get cache location
|
||||
|
||||
> Note: This requires pip 20.1+
|
||||
```yaml
|
||||
- name: Get pip cache dir
|
||||
id: pip-cache
|
||||
run: |
|
||||
python -m pip install -U "pip>=20.1"
|
||||
echo "::set-output name=dir::$(pip cache dir)"
|
||||
|
||||
- name: pip cache
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.pip-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-pip-
|
||||
```
|
||||
|
||||
### Using a script to get cache location
|
||||
|
||||
> Note: This uses an internal pip API and may not always work
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue