Skip to content

Commit

Permalink
Document switching PHP/Composer versions
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Nov 12, 2020
1 parent d0a80b2 commit 6271df6
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# These are supported funding model platforms
github: [g105b]
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
50 changes: 37 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<img src="http://52.48.57.141/php-actions.png" align="right" alt="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.

Expand All @@ -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:

Expand All @@ -43,7 +43,7 @@ jobs:
...

- name: Install dependencies
uses: php-actions/composer@v2
uses: php-actions/composer@v4
with:
command: your-command-here
```
Expand Down Expand Up @@ -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
--------------------------------------

Expand All @@ -96,28 +120,28 @@ jobs:
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
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
...
```
Expand Down Expand Up @@ -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

0 comments on commit 6271df6

Please sign in to comment.