Skip to content

matchory/php-composer-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Composer Action

An action to run composer commands in a GitHub Actions workflow.

Usage

This action can be used to run any composer command. By default, it runs composer install with sensible configuration out of the box:

name: Composer Action Example
on: [ push ]

jobs:
  composer:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Run Composer Action
        uses: actions/composer-action@v1

You can also specify a different command to run by using the args input:

name: Composer Action Example
on: [ push ]

jobs:
  composer:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Run Composer Action
        uses: actions/composer-action@v1
        with:
          args: outdated --direct --format=json

Configuration

Inputs

The action has some common inputs:

Input Description Required Default
args Arguments to pass to composer. Accepts any valid Composer command args. If install (the default) or update, it will run the command with the configured option flags. No install
verbosity Set the verbosity level. Must be one of: normal, quiet, verbose, veryverbose", or debug. No normal
working-directory The working directory to run the command in. No
no-plugins Whether to disable plugins. No false
no-scripts Skips the execution of all scripts defined in composer.json. No false

It also provides additional convenience inputs that will only be applied with the install and update commands:

Input Description Required Default
prefer Specify package source preference. Must be one of: auto, dist, or source. No auto
no-dev Disables installation of require-dev packages. No false
autoloader Configures autoloader generation. Must be one of: true, false, optimize, classma",or apcu`. No optimize
audit Run an audit after installation is complete. Also takes an audit format name. Must be one of: true (equivalent to summary), false, table, or plain, json, or summary. No false
ignore-platform-reqs Ignore platform requirements. Must be one of: true, false, or a comma-separated list of platform requirements to ignore. No false
cache Whether to use cache. No true
artifact Name of generated vendor artifact. No
artifact-path Path of generated vendor artifact. No vendor.tar.gz
artifact-retention-days Number of days that the vendor artifact should be retained for. No 7

Some of the inputs are described in detail below.

Outputs

Output Description
artifact Name of the generated vendor artifact.
artifact-path Path of generated vendor artifact.
composer-cache-dir Composer cache directory.

Autoloader Generation

Autoloader generation is enabled by default. You can configure this by setting the autoloader input to one of the following values:

  • true - Generates the autoloader without optimizations (composer's default behavior).
  • false - Disables autoloader generation (equivalent to passing no-autoloader to composer).
  • optimize - Generates an optimized autoloader.
  • classmap - Generates an authoritative class map autoloader.
  • apcu - Generates an APCu autoloader.

Refer to the Composer documentation for more details on autoloader generation and optimization levels.

Audit

The action can run an audit after installation is complete. This is enabled by setting the audit input to one of the following values:

  • true - Equivalent to summary.
  • false - Disables audit.
  • table - Displays audit results in a table format.
  • plain - Displays audit results in a plain text format.
  • json - Displays audit results in a JSON format.
  • summary - Displays audit results in a summary format.

This combines the --audit and --audit-format options. The default value is false, which disables the audit.
When enabled. The action will fail if the audit finds any issues.

Ignoring Platform Requirements

The action can configure composer to ignore (some) platform requirements. This is enabled by setting the ignore-platform-reqs input to one of the following values:

  • true - Ignores all platform requirements.
  • false - Does not ignore any platform requirements (composer's default behavior).
  • <comma-separated list> - Ignores the specified platform requirements. This can be a comma-separated list of platform requirements to ignore, such as ext-curl,ext-json.

Refer to the Composer documentation for more

Cache

The action can use a cache to speed up installation. This is enabled by setting the cache input to true (default) or false. If enabled, the action will use the cache directory specified by the COMPOSER_CACHE_DIR environment variable. If this variable is not set, the action will use the default cache directory for Composer, which is $HOME/.composer/cache on Linux and macOS, and %LOCALAPPDATA%/Composer/cache on Windows.

Artifact

The action can generate an artifact from the compressed vendor folder. This is enabled by setting the artifact input to true. The archive will be generated in the working directory and will be named vendor.tar.gz by default.
You can change the name of the artifact by setting the artifact-path input to a different path.

About

A GitHub Action to run composer commands.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors