Skip to content

Commit 6271df6

Browse files
author
Greg Bowler
committed
Document switching PHP/Composer versions
1 parent d0a80b2 commit 6271df6

File tree

3 files changed

+40
-14
lines changed

3 files changed

+40
-14
lines changed

.github/FUNDING.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# These are supported funding model platforms
2+
github: [g105b]

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM ghcr.io/php-actions/php-build:latest
1+
FROM ghcr.io/php-actions/php-build:v1
22

33
LABEL repository="https://github.com/php-actions/composer"
44
LABEL homepage="https://github.com/php-actions/composer"

README.md

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<img src="http://52.48.57.141/php-actions.png" align="right" alt="PHP Actions for Github" />
22

33
Use the Composer CLI in your Github Actions.
4-
==============================================
4+
============================================
55

66
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.
77

@@ -25,14 +25,14 @@ jobs:
2525

2626
steps:
2727
- uses: actions/checkout@v2
28-
- uses: php-actions/composer@v2
28+
- uses: php-actions/composer@v4
2929
# ... then your own project steps ...
3030
```
3131

3232
Running custom commands
3333
-----------------------
3434

35-
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).
35+
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).
3636

3737
You can issue custom commands by passing a `command` input, like so:
3838

@@ -43,7 +43,7 @@ jobs:
4343
...
4444

4545
- name: Install dependencies
46-
uses: php-actions/composer@v2
46+
uses: php-actions/composer@v4
4747
with:
4848
command: your-command-here
4949
```
@@ -72,13 +72,37 @@ jobs:
7272
...
7373
7474
- name: Install dependencies
75-
uses: php-actions/composer@v2
75+
uses: php-actions/composer@v4
7676
with:
7777
suggest: yes
7878
dev: no
7979
args: --profile --ignore-platform-reqs
8080
```
8181

82+
Using different versions of PHP or Composer
83+
-------------------------------------------
84+
85+
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.
86+
87+
Use the following inputs to run a specific PHP/Composer version combination:
88+
89+
+ `php_version` Available versions: `7.1`, `7.2`, `7.3`, `7.4`, `8.0` (default: `latest` aka: `7.4`)
90+
+ `composer_version` Available versions: `1`, `2` (default: `latest` aka: `2`)
91+
92+
Example configuration that runs Composer version 1 on PHP version 7.1:
93+
```yaml
94+
jobs:
95+
build:
96+
97+
...
98+
99+
- name: Install dependencies
100+
uses: php-actions/composer@v4
101+
with:
102+
php_version: 7.1
103+
composer_version: 1
104+
```
105+
82106
Caching dependencies for faster builds
83107
--------------------------------------
84108

@@ -96,28 +120,28 @@ jobs:
96120
runs-on: [ubuntu-latest]
97121
98122
steps:
99-
- uses: actions/checkout@v1
123+
- uses: actions/checkout@v2
100124
101125
- name: Get Composer Cache Directory
102126
id: composer-cache
103127
run: |
104128
echo "::set-output name=dir::$(composer config cache-files-dir)"
105129
106130
- name: Cache Composer Downloads
107-
uses: actions/cache@v1
131+
uses: actions/cache@v2
108132
with:
109-
path: ${{ steps.composer-cache.outputs.dir }}
133+
path: vendor/
110134
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
111135
restore-keys: |
112-
${{ runner.os }}-composer-
136+
${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
113137
114138
- name: Cache PHP dependencies
115-
uses: actions/cache@v1
139+
uses: actions/cache@v2
116140
with:
117141
path: vendor
118-
key: ${{ runner.OS }}-build-${{ hashFiles('**/composer.lock') }}
142+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
119143
120-
- uses: php-actions/composer@master
144+
- uses: php-actions/composer@v4
121145
122146
...
123147
```
@@ -157,4 +181,4 @@ If you found this repository helpful, please consider [sponsoring the developer]
157181
[php-actions-behat]: https://github.com/marketplace/actions/behat-php-actions
158182
[deploy-keys]: https://docs.github.com/en/developers/overview/managing-deploy-keys
159183
[secrets]: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
160-
[sponsor]: https://github.com/sponsors/g105b
184+
[sponsor]: https://github.com/sponsors/g105b

0 commit comments

Comments
 (0)