Skip to content

baschny/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

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

baschny/php-composer-action

This GitHub action allows to run the latest composer on your source code.

It uses the official composer docker image and allows efficient caching of downloaded assets.

Input

  • composer_version: Major version to install. Basically any tag name from https://hub.docker.com/_/composer - i.e. 1 or 2. Defaults to latest.

  • command: The composer command to run, defaults to install. Set to get_config to only generate the output variables of the composer setup (for use in cache, see example below)

  • args: Other command line arguments to pass to composer, defaults to --optimize-autoloader --no-progress

  • github_oauth: If your composer needs access to a private repo, configure the github OAuth token to use here. For example it could come from a secret, i.e. secrets.GITHUB_OAUTH.

Output

  • composer_cache_dir: where the composer cache is located, in case you want to use actions/cache

  • composer_major_version: the detected major version of composer, useful to have a separate cache tag based on this, since there can be slight differences in the caches between major versions.

  • composer_version: the exact composer version, in case you want to output this somewhere.

Example Workflow

name: PHP Building Workflow

on: [push]

jobs:

  composer_install:
    runs-on: ubuntu-latest

    env:
      COMPOSER_VERSION: 1

    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

      - name: Get composer cache directory
        id: composer_config
        uses: baschny/php-composer-action@v1
        with:
          composer_version: ${{ env.COMPOSER_VERSION }}
          command: get_config

      - name: Cache composer downloads
        uses: actions/cache@v2
        with:
          path: ${{ steps.composer_config.outputs.composer_cache_dir }}
          key: composer-v${{ steps.composer_config.outputs.composer_major_version }}

      - name: Run composer install
        uses: baschny/php-composer-action@v1
        with:
          composer_version: ${{ env.COMPOSER_VERSION }}
          command: install
          #github_oauth: ${{ secret.GITHUB_OAUTH }}

License

See LICENSE file.

See also

The idea came after some brainstorming in https://github.com/php-actions/composer.

Author

Ernesto Baschny, cron IT GmbH

About

A GitHub action to call php composer on your project

Resources

License

Stars

Watchers

Forks

Packages

No packages published