Skip to content
package

GitHub Action

Composer Action

v1.1.0 Latest version

Composer Action

package

Composer Action

Do Composer commands in your actions

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Composer Action

uses: MilesChou/[email protected]

Learn more about this action in MilesChou/composer-action

Choose a version

Docker and GitHub Actions for Composer

GitHub Release License

Testing Publish Docker

GitHub Actions for Composer. Base on Docker official PHP image, and installed hirak/prestissimo package.

Why build another one image?

Actually, I want to follow DRY principle and use official Composer image. But see the following composer.json:

{
    "require": {
        "php": ">=5.5.9"
    },
    "require-dev": {
        "phpunit/phpunit": "^4 | ^5 | ^6"
    }
}

And use the following workflow:

- name: Composer install
  uses: docker://composer:1.9.1
  with:
    args: install
- name: PHPUnit testing
  uses: docker://php:5.5
  with:
    args: php vendor/bin/phpunit

It's expected to work on PHP 5.5 ~ 7.3, so we should test on every platform. However, Composer image will install on PHP 7.3 platform and it will install PHPUnit 6.x. It will failed on PHP 5.5 container for PHPUnit 6.x require PHP ^7.0.

Of course, we can use the config.platform.php config to force platform version on PHP 5.5 and it will install PHPUnit 4.x, but PHPUnit 4.x use too many deprecated functions, e.g. each(), so that cannot work on PHP >=7.2.

Finally, I think that build image on every version is the good idea.

Usage for GitHub Actions

Via GitHub Workflow

- uses: MilesChou/composer-action@master
  with:
    args: install

Use install image

- uses: MilesChou/composer-action/install@master

With specify PHP version

- uses: MilesChou/composer-action/5.5/install@master

Usage for Docker

See Docker Hub

Usage for GitHub Container Registry

See GitHub Container Registry

Supported tags and respective Dockerfile links

Notice: Default tags is using Composer v2.

Here is tags for using Composer v1:

The following is built-in tools:

Credits

License

The MIT License (MIT). Please see License File for more information.