mirror of
https://github.com/shivammathur/setup-php.git
synced 2024-11-26 13:23:05 +07:00
Merge pull request #70 from shivammathur/develop
Update cache dependencies section in README
This commit is contained in:
commit
e5076cee70
32
README.md
32
README.md
@ -176,20 +176,30 @@ jobs:
|
|||||||
|
|
||||||
### Cache dependencies
|
### Cache dependencies
|
||||||
|
|
||||||
You can cache you dependencies using the [`action/cache`](https://github.com/actions/cache) GitHub Action and add a condition in your `composer install` step to run only if your dependencies are not cached. The files cached using this method are available across check-runs and will reduce the workflow execution time.
|
You can persist composer's internal cache directory using the [`action/cache`](https://github.com/actions/cache) GitHub Action. Dependencies cached are loaded directly instead of downloading them while installation. The files cached are available across check-runs and will reduce the workflow execution time.
|
||||||
|
|
||||||
|
**Note:** Please do not cache `vendor` directory using `action/cache` as that will have side-effects.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Cache dependencies
|
- name: Get Composer Cache Directory
|
||||||
- uses: actions/cache@preview
|
id: composer-cache
|
||||||
id: cache
|
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||||
|
- name: Cache on linux and macOS
|
||||||
|
if: matrix.operating-system != 'windows-latest'
|
||||||
|
uses: actions/cache@v1
|
||||||
with:
|
with:
|
||||||
path: vendor
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||||
restore-keys: |
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
${{ runner.os }}-php-
|
- name: Cache on windows
|
||||||
- name: Install dependencies
|
if: matrix.operating-system == 'windows-latest'
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
uses: actions/cache@v1
|
||||||
run: composer install
|
with:
|
||||||
|
path: ${{ steps.composer-cache.outputs.dir }}
|
||||||
|
key: ${{ runner.os }}-composer-${{ hashFiles('**composer.lock') }}
|
||||||
|
restore-keys: ${{ runner.os }}-composer-
|
||||||
|
- name: Install Dependencies
|
||||||
|
run: composer install --prefer-dist
|
||||||
```
|
```
|
||||||
|
|
||||||
### Examples
|
### Examples
|
||||||
|
Loading…
Reference in New Issue
Block a user