|
| 1 | +baschny/action-php-composer |
| 2 | +=========================== |
| 3 | + |
| 4 | +This GitHub action allows to run the latest composer on your source code. |
| 5 | + |
| 6 | +It uses the official composer docker image and allows efficient caching of |
| 7 | +downloaded assets. |
| 8 | + |
| 9 | +Input |
| 10 | +----- |
| 11 | +* `composer_version`: Major version to install. Basically any tag name from https://hub.docker.com/_/composer - |
| 12 | + i.e. `1` or `2`. Defaults to `latest`. |
| 13 | + |
| 14 | +* `command`: The composer command to run, defaults to `install`. Set to `get_config` to only generate the output |
| 15 | + variables of the composer setup (for use in cache, see example below) |
| 16 | + |
| 17 | +* `args`: Other command line arguments to pass to composer, defaults to `--optimize-autoloader --no-progress` |
| 18 | + |
| 19 | +Output |
| 20 | +------ |
| 21 | +* `composer_cache_dir`: where the composer cache is located, in case you want to use `actions/cache` |
| 22 | + |
| 23 | +* `composer_major_version`: the detected major version of composer, useful to have a separate cache tag based on |
| 24 | + this, since there can be slight differences in the caches between major versions. |
| 25 | + |
| 26 | +* `composer_version`: the exact composer version, in case you want to output this somewhere. |
| 27 | + |
| 28 | +Example Workflow |
| 29 | +---------------- |
| 30 | + |
| 31 | +```yaml |
| 32 | +name: PHP Building Workflow |
| 33 | + |
| 34 | +on: [push] |
| 35 | + |
| 36 | +jobs: |
| 37 | + |
| 38 | + composer_install: |
| 39 | + runs-on: ubuntu-latest |
| 40 | + |
| 41 | + env: |
| 42 | + COMPOSER_VERSION: 1 |
| 43 | + |
| 44 | + steps: |
| 45 | + - name: Checkout repository |
| 46 | + uses: actions/checkout@v2 |
| 47 | + |
| 48 | + - name: Get composer cache directory |
| 49 | + id: composer_config |
| 50 | + uses: baschny/action-php-composer |
| 51 | + with: |
| 52 | + composer_version: ${{ env.COMPOSER_VERSION }} |
| 53 | + command: get_config |
| 54 | + |
| 55 | + - name: Cache composer downloads |
| 56 | + uses: actions/cache@v2 |
| 57 | + with: |
| 58 | + path: ${{ steps.composer_config.outputs.composer_cache_dir }} |
| 59 | + key: composer-v${{ steps.composer_config.outputs.composer_major_version }} |
| 60 | + |
| 61 | + - name: Run composer install |
| 62 | + uses: baschny/action-php-composer |
| 63 | + with: |
| 64 | + composer_version: ${{ env.COMPOSER_VERSION }} |
| 65 | + command: install |
| 66 | +``` |
| 67 | +
|
| 68 | +License |
| 69 | +------- |
| 70 | +
|
| 71 | +See LICENSE file. |
| 72 | +
|
| 73 | +See also |
| 74 | +-------- |
| 75 | +
|
| 76 | +The idea came after some brainstorming in https://github.com/php-actions/composer. |
| 77 | +
|
| 78 | +Author |
| 79 | +------ |
| 80 | +
|
| 81 | +Ernesto Baschny, cron IT GmbH |
0 commit comments