Skip to content

Commit

Permalink
Document caching
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Dec 8, 2019
1 parent 9754dde commit be4d170
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,63 @@ jobs:

steps:
- uses: actions/checkout@v1
- uses: phpactions/composer@master
- uses: php-actions/composer@v1
# ... then your own project steps ...
```

Running custom commands
-----------------------

By default, adding `- uses: php-actions/composer@v1` into your workflow will run `composer install`, as `install` is the default command name.

You can issue custom commands by passing a `command` input, like so:

```yaml
...

jobs:
build:

...

- name: Install dependencies
uses: php-actions/composer@v1
with:
command: your-command-here
```
Caching dependencies for faster builds
--------------------------------------
Github actions supports dependency caching, allowing the `vendor/` directory contents to be cached between workflows, as long as the `composer.lock` file has not changed. This produces much faster builds, as the `composer install` command does not have to be run at all if the cache is valid.

Example workflow (taken from https://github.com/PhpGt/Dom):

```yaml
name: CI
on: [push]
jobs:
build:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- name: Cache PHP dependencies
uses: actions/cache@v1
with:
path: vendor
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
- uses: php-actions/composer@master
...
```

In the example above, the "key" is passed to the Cache action that consists of a hash of the composer.lock file. This means that as long as the contents of composer.lock doesn't change between workflows, the vendor directory will be persisted between workflows.

[php-actions-phpunit]: https://github.com/marketplace/actions/phpunit-php-actions
[php-actions-phpspec]: https://github.com/marketplace/actions/phpspec-php-actions
[php-actions-behat]: https://github.com/marketplace/actions/behat-php-actions
[php-actions-behat]: https://github.com/marketplace/actions/behat-php-actions

0 comments on commit be4d170

Please sign in to comment.