Skip to content

Commit

Permalink
feat(composer-install): use our own docker image rather than a 3rd pa…
Browse files Browse the repository at this point in the history
…rty action
  • Loading branch information
EdieLemoine committed Jun 2, 2023
1 parent f5ed899 commit e221147
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 25 deletions.
17 changes: 10 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,9 @@ Can be used with Yarn 1 and Yarn 2 (berry).

[Source](composer-install/action.yml)

1. Sets up php@7.2 with composer v2
1. Pulls [`myparcelnl/php-xd`]
- You can change the php version by passing `php-version`.
- You can change the composer version or install any other tools by
passing `tools`.
See [shivammathur/setup-php](https://github.com/shivammathur/setup-php#wrench-tools-support)
for supported values.
2. Handles cache
2. Handles composer cache
3. Runs `composer install --no-interaction --no-progress`
- You can add additional flags by passing the `flags` option.

Expand All @@ -286,10 +282,16 @@ Can be used with Yarn 1 and Yarn 2 (berry).
- uses: myparcelnl/actions/composer-install@v3
with:
php-version: '8.0'
tools: php-cs-fixer, phpunit
flags: --no-dev --no-plugins
```

##### Inputs

| Required | Name | Description | Example | Default |
| -------- | ------------- | ---------------------------------------------- | -------------- | ------- |
| No | `php-version` | The PHP version to use | `8.0` | `7.2` |
| No | `flags` | Additional flags to pass to `composer install` | `--no-scripts` ||

### Testing

#### update-coverage
Expand Down Expand Up @@ -788,3 +790,4 @@ Save and restore the [Nx](https://nx.dev/) cache.
[semantic-release]: #semantic-release
[setup-git-credentials]: #setup-git-credentials
[yarn-install]: #yarn-install
[`myparcelnl/php-xd`]: https://github.com/myparcelnl/docker-images/pkgs/container/php-xd
33 changes: 15 additions & 18 deletions composer-install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,32 @@ inputs:
default: '7.2'
required: false

tools:
description: 'Tools to pass to shivammathur/setup-php.'
default: 'composer:v2'
required: false

flags:
description: 'Flags to use when installing composer dependencies.'
required: false
default: ''

runs:
using: composite
steps:
- name: 'Set up PHP'
uses: shivammathur/setup-php@v2
with:
php-version: ${{ inputs.php-version }}
tools: ${{ inputs.tools }}

- name: 'Prepare Composer cache'
- name: 'Handle composer cache'
uses: actions/cache@v3
id: cache
with:
path: vendor
key: ${{ runner.os }}-composer-vendor-${{ hashFiles('**/composer.lock') }}
path: $HOME/.composer
key: composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-vendor-
composer-${{ hashFiles('**/composer.json') }}-
composer-
- uses: myparcelnl/actions/pull-docker-image@v3
with:
image: ghcr.io/myparcelnl/php-xd:${{ inputs.php-version }}-cli-alpine

- name: 'Install composer dependencies'
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
composer install --no-interaction --no-progress ${{ inputs.flags }}
docker compose run \
--volume $HOME/.composer:/root/.composer \
--env COMPOSER_CACHE_DIR=/root/.composer \
php \
composer install --no-interaction --no-progress ${{ inputs.flags }}

0 comments on commit e221147

Please sign in to comment.