|
| 1 | +name: "Install PHP Dependencies" |
| 2 | +description: "Install PHP Dependencies" |
| 3 | +inputs: |
| 4 | + php-version: |
| 5 | + description: "PHP Version" |
| 6 | + required: false |
| 7 | + default: "8.5" |
| 8 | + display: |
| 9 | + description: "Vendor Script Name for Display, e.g. PHPUnit" |
| 10 | + required: false |
| 11 | + cache: |
| 12 | + description: "Vendor Script Cache Path, e.g. build/phpstan" |
| 13 | + required: false |
| 14 | + command: |
| 15 | + description: "Vendor Script Command, e.g. php vendor/bin/phpstan analyse --no-progress" |
| 16 | + required: false |
| 17 | +runs: |
| 18 | + using: "composite" |
| 19 | + steps: |
| 20 | + - name: Set Up Build Cache for Composer |
| 21 | + uses: actions/cache@v4 |
| 22 | + with: |
| 23 | + path: build/composer |
| 24 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}-${{ github.run_id }} |
| 25 | + restore-keys: | |
| 26 | + ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} |
| 27 | + ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 28 | + ${{ runner.os }}-composer |
| 29 | +
|
| 30 | + - name: Set Up Vendor Cache for Composer |
| 31 | + uses: actions/cache@v4 |
| 32 | + with: |
| 33 | + path: vendor |
| 34 | + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }}-${{ github.run_id }} |
| 35 | + restore-keys: | |
| 36 | + ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ hashFiles('**/composer.lock') }} |
| 37 | + ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} |
| 38 | + ${{ runner.os }}-composer |
| 39 | +
|
| 40 | + - if: ${{ inputs.cache != '' }} |
| 41 | + name: Set Up Cache for ${{ inputs.name }} |
| 42 | + uses: actions/cache@v4 |
| 43 | + with: |
| 44 | + path: ${{ inputs.cache }} |
| 45 | + key: ${{ runner.os }}-${{ inputs.php-version }}-${{ inputs.cache }}-${{ hashFiles('**/composer.lock') }} |
| 46 | + restore-keys: ${{ runner.os }}-${{ inputs.php-version }}-${{ inputs.cache }} |
| 47 | + |
| 48 | + - name: Install Composer Dependencies |
| 49 | + shell: bash |
| 50 | + run: | |
| 51 | + mkdir -p build/composer |
| 52 | + docker run --rm \ |
| 53 | + --user="$(id -u):$(id -g)" \ |
| 54 | + --pull=missing \ |
| 55 | + --env COMPOSER_CACHE_DIR="build/composer" \ |
| 56 | + --volume ${{ github.workspace }}:/app \ |
| 57 | + composer:latest \ |
| 58 | + composer install --no-interaction --no-progress --prefer-dist --optimize-autoloader |
| 59 | +
|
| 60 | + - if: ${{ inputs.cache != '' }} |
| 61 | + name: Make Command Cache Directory |
| 62 | + shell: bash |
| 63 | + run: mkdir -p ${{ inputs.cache }} |
| 64 | + |
| 65 | + - if: ${{ inputs.command != '' }} |
| 66 | + name: Run ${{ inputs.display }} |
| 67 | + shell: bash |
| 68 | + run: | |
| 69 | + docker run --rm \ |
| 70 | + --user="$(id -u):$(id -g)" \ |
| 71 | + --pull=missing \ |
| 72 | + --volume ${{ github.workspace }}:/app \ |
| 73 | + php:${{ inputs.php-version }}-cli-alpine \ |
| 74 | + ${{ inputs.command != '' }} |
0 commit comments