From 6271df6011f84bcfd4db8b9c934a2631c605501e Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Thu, 12 Nov 2020 12:05:47 +0000 Subject: [PATCH] Document switching PHP/Composer versions --- .github/FUNDING.yml | 2 ++ Dockerfile | 2 +- README.md | 50 +++++++++++++++++++++++++++++++++------------ 3 files changed, 40 insertions(+), 14 deletions(-) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..fb4803d --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,2 @@ +# These are supported funding model platforms +github: [g105b] \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 8bbf1f9..508a22e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM ghcr.io/php-actions/php-build:latest +FROM ghcr.io/php-actions/php-build:v1 LABEL repository="https://github.com/php-actions/composer" LABEL homepage="https://github.com/php-actions/composer" diff --git a/README.md b/README.md index 9364570..b3fbaf2 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ PHP Actions for Github Use the Composer CLI in your Github Actions. -============================================== +============================================ Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on, and it will manage (install/update) them for you. @@ -25,14 +25,14 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: php-actions/composer@v2 + - uses: php-actions/composer@v4 # ... then your own project steps ... ``` Running custom commands ----------------------- -By default, adding `- uses: php-actions/composer@v2` into your workflow will run `composer install`, as `install` is the default command name. The install command will be provided with a default set of arguments (see below). +By default, adding `- uses: php-actions/composer@v4` into your workflow will run `composer install`, as `install` is the default command name. The install command will be provided with a default set of arguments (see below). You can issue custom commands by passing a `command` input, like so: @@ -43,7 +43,7 @@ jobs: ... - name: Install dependencies - uses: php-actions/composer@v2 + uses: php-actions/composer@v4 with: command: your-command-here ``` @@ -72,13 +72,37 @@ jobs: ... - name: Install dependencies - uses: php-actions/composer@v2 + uses: php-actions/composer@v4 with: suggest: yes dev: no args: --profile --ignore-platform-reqs ``` +Using different versions of PHP or Composer +------------------------------------------- + +This action runs on a custom base image, available at https://github.com/php-actions/php-build which allows for switching the active PHP version on-the-fly, and this repository allows switching of Composer versions on-the-fly. + +Use the following inputs to run a specific PHP/Composer version combination: + ++ `php_version` Available versions: `7.1`, `7.2`, `7.3`, `7.4`, `8.0` (default: `latest` aka: `7.4`) ++ `composer_version` Available versions: `1`, `2` (default: `latest` aka: `2`) + +Example configuration that runs Composer version 1 on PHP version 7.1: +```yaml +jobs: + build: + + ... + + - name: Install dependencies + uses: php-actions/composer@v4 + with: + php_version: 7.1 + composer_version: 1 +``` + Caching dependencies for faster builds -------------------------------------- @@ -96,7 +120,7 @@ jobs: runs-on: [ubuntu-latest] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 - name: Get Composer Cache Directory id: composer-cache @@ -104,20 +128,20 @@ jobs: echo "::set-output name=dir::$(composer config cache-files-dir)" - name: Cache Composer Downloads - uses: actions/cache@v1 + uses: actions/cache@v2 with: - path: ${{ steps.composer-cache.outputs.dir }} + path: vendor/ key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: | - ${{ runner.os }}-composer- + ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - name: Cache PHP dependencies - uses: actions/cache@v1 + uses: actions/cache@v2 with: path: vendor - key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - - uses: php-actions/composer@master + - uses: php-actions/composer@v4 ... ``` @@ -157,4 +181,4 @@ If you found this repository helpful, please consider [sponsoring the developer] [php-actions-behat]: https://github.com/marketplace/actions/behat-php-actions [deploy-keys]: https://docs.github.com/en/developers/overview/managing-deploy-keys [secrets]: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets -[sponsor]: https://github.com/sponsors/g105b +[sponsor]: https://github.com/sponsors/g105b \ No newline at end of file