• Stars
    star
    215
  • Rank 177,401 (Top 4 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 3 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐ŸŽ A GitHub Action to streamline installation of PHP dependencies with Composer.

ramsey/composer-install

A GitHub Action to streamline installation of PHP dependencies with Composer.

Source Code Read License Build Status Codecov Code Coverage

About

ramsey/composer-install is a GitHub Action to streamline installation of Composer dependencies in workflows. It installs your Composer dependencies and caches them for improved build times.

This project adheres to a code of conduct. By participating in this project and its community, you are expected to uphold this code.

Dependencies

This GitHub Action requires PHP and Composer. One way to ensure you have both is to use the Setup PHP GitHub Action.

The step that sets up PHP and Composer for your environment must come before the ramsey/composer-install step.

Usage

Use ramsey/composer-install as step within a job. This example also shows use of the Setup PHP action as a step.

- uses: "shivammathur/setup-php@v2"
  with:
    php-version: "latest"
- uses: "ramsey/composer-install@v2"

๐Ÿ’ก There is no need to set up a separate caching step since ramsey/composer-install handles this for you.

Input Parameters

dependency-versions

The dependency-versions input parameter allows you to select whether the job should install the locked, highest, or lowest versions of Composer dependencies.

Valid values are:

  • locked: (default) installs the locked versions of Composer dependencies (equivalent to running composer install)

  • highest: installs the highest versions of Composer dependencies (equivalent to running composer update)

  • lowest: installs the lowest versions of Composer dependencies (equivalent to running composer update --prefer-lowest --prefer-stable)

For example:

- uses: "ramsey/composer-install@v2"
  with:
    dependency-versions: "lowest"

composer-options

ramsey/composer-install always passes the --no-interaction, --no-progress, and --ansi options to the composer command. If you'd like to pass additional options, you may use the composer-options input parameter.

For example:

- uses: "ramsey/composer-install@v2"
  with:
    composer-options: "--ignore-platform-reqs --optimize-autoloader"

working-directory

The working-directory input parameter allows you to specify a different location for your composer.json file. For example, if your composer.json is located in packages/acme-foo/, use working-directory to tell ramsey/composer-install where to run things.

- uses: "ramsey/composer-install@v2"
  with:
    working-directory: "packages/acme-foo"

You may use this step as many times as needed, if you have multiple composer.json files.

For example:

# Install dependencies using composer.json in the root.
- uses: "ramsey/composer-install@v2"

# Install dependencies using composer.json in src/Component/Config/
- uses: "ramsey/composer-install@v2"
  with:
    working-directory: "src/Component/Config"

# Install dependencies using composer.json in src/Component/Validator/
- uses: "ramsey/composer-install@v2"
  with:
    working-directory: "src/Component/Validator"

ignore-cache

If you have jobs for which you wish to completely ignore the caching step, you may use the ignore-cache input parameter. When present, ramsey/composer-install will neither read from nor write to the cache.

Values of 'yes', true, or 1 will tell the action to ignore the cache. For any other value, the action will use the default behavior, which is to read from and store to the cache.

- uses: "ramsey/composer-install@v2"
  with:
    ignore-cache: "yes"

custom-cache-key

There may be times you wish to specify your own cache key. You may do so with the custom-cache-key input parameter. When provided, ramsey/composer-install will not use the auto-generated cache key, so if your composer.json or composer.lock files change, you'll need to update the custom cache key if you wish to update the cache.

- uses: "ramsey/composer-install@v2"
  with:
    custom-cache-key: "my-custom-cache-key"

custom-cache-suffix

ramsey/composer-install will auto-generate a cache key which is composed of the following elements:

  • The OS image name, like ubuntu-latest.
  • The exact PHP version, like 8.1.11.
  • The options passed via composer-options.
  • The dependency version setting as per dependency-versions.
  • The working directory as per working-directory.
  • A hash of the composer.json and/or composer.lock files.

If you don't want to generate your own cache key, but do want to make the cache key even more specific, you can specify a suffix to be added to the cache key via the custom-cache-suffix parameter.

# Adds a suffix to the cache key which is equivalent to the full date-time
# of "last Monday 00:00", which means that the cache will be force refreshed
# via the first workflow which is run every Monday.
- uses: "ramsey/composer-install@v2"
  with:
    custom-cache-suffix: $(/bin/date -u --date='last Mon' "+%F")

โš ๏ธ Note: specifying a custom-cache-key will take precedence over the custom-cache-suffix.

Fork and private repositories

Sometimes it's needed to use the repositories key in your composer.json to pull in forks, PRs with patches or private repositories. In this case, your GitHub Action may start failing with a Could not authenticate against github.com error message. To solve this, you need to add a GitHub Personal Access token, and this bit to your Action configuration:

env:
   COMPOSER_AUTH: '{"github-oauth": {"github.com": "${{ secrets.COMPOSER_AUTH }}"}}'

In this example, COMPOSER_AUTH is the name of the secret that you'll need to create. To access public repositories, the public_repo scope is sufficient, while for private repositories (that you can access), read:project will be needed.

For more information on how to do that on your repository, see Creating a personal access token and Creating encrypted secrets for a repository on GitHub documentation.

Matrix Example

GitHub Workflows allow you to set up a job matrix, which allows you to configure multiple jobs for the same steps by using variable substitution in the job definition.

Here's an example of how you might use the dependency-versions and composer-options input parameters as part of a job matrix.

strategy:
  matrix:
    php:
      - "7.4"
      - "8.0"
      - "8.1"
    dependencies:
      - "lowest"
      - "highest"
    include:
      - php-version: "8.2"
        composer-options: "--ignore-platform-reqs"

steps:
  - uses: "actions/checkout@v3"
  - uses: "shivammathur/setup-php@v2"
    with:
      php-version: "${{ matrix.php }}"
  - uses: "ramsey/composer-install@v2"
    with:
      dependency-versions: "${{ matrix.dependencies }}"
      composer-options: "${{ matrix.composer-options }}"

Contributing

Contributions are welcome! Before contributing to this project, familiarize yourself with CONTRIBUTING.md.

Copyright and License

The ramsey/composer-install GitHub Action is copyright ยฉ Ben Ramsey and licensed for use under the terms of the MIT License (MIT). Please see LICENSE for more information.

More Repositories

1

uuid

โ„๏ธ A PHP library for generating universally unique identifiers (UUIDs).
PHP
12,301
star
2

collection

๐Ÿ—‚๏ธ A PHP library for representing and manipulating collections.
PHP
1,051
star
3

uuid-doctrine

โ„๏ธ๐Ÿ—„๏ธ Allow the use of a ramsey/uuid UUID as Doctrine field type.
PHP
874
star
4

array_column

Provides functionality for array_column() to projects using PHP earlier than version 5.5.
PHP
373
star
5

php-library-starter-kit

๐Ÿ—๏ธ A tool to quickly set up the base files of a PHP library project.
PHP
238
star
6

conventional-commits

๐Ÿช€ A PHP library for creating and validating commit messages according to the Conventional Commits specification. Includes a CaptainHook plugin!
PHP
174
star
7

composer-repl

๐Ÿš A REPL for PHP built into Composer (using PsySH)
97
star
8

macos-vagrant-box

Scripts to generate Vagrant boxes for macOS
Shell
96
star
9

devtools

๐Ÿงฐ A Composer plugin to aid PHP library and application development.
64
star
10

uuid-console

A console application for generating UUIDs with ramsey/uuid.
PHP
39
star
11

identifier

A PHP library for generating and working with identifiers, including UUIDs, ULIDs, and Snowflakes
PHP
38
star
12

vagrant-php-src-dev

Uses Vagrant to provision a basic virtual environment for hacking on the PHP core.
Puppet
37
star
13

jenkins-php

A meta package for the PHP Quality Assurance Toolchain tools required by the Template for Jenkins Jobs for PHP Projects, http://jenkins-php.org/
35
star
14

php-rfcs

PHP
34
star
15

http-range

A PHP library for parsing and handling HTTP range requests.
PHP
30
star
16

laravel-oauth2-instagram

A Laravel 5 service provider for league/oauth2-instagram
PHP
29
star
17

beatles

The Beatles programming language
24
star
18

devtools-lib

๐Ÿงฐ๐Ÿ“š The library behind ramsey/devtools, allowing for extension of the ramsey/devtools Composer plugin.
PHP
21
star
19

twig-codeblock

Syntax highlighting for Twig with the {% codeblock %} tag.
PHP
19
star
20

oauth2-example

Full Laravel source application for example in "Mastering OAuth 2.0" articles and talks.
PHP
17
star
21

vnderror

application/vnd.error builder/formatter for PHP 5.3+
PHP
17
star
22

php-museum-exhibits

HTML
15
star
23

ext-ecma_intl

A PHP implementation of the ECMAScript 2023 Internationalization API Specification (ECMA-402)
C
9
star
24

gitea-environment

Shell
9
star
25

math

This package is abandoned. Try brick/math instead: https://github.com/brick/math
PHP
8
star
26

dotfiles

The dotfiles I use on my systems
Vim Script
8
star
27

coding-standard

๐Ÿงผ A common coding standard for @ramsey's PHP libraries.
PHP
7
star
28

pdo_oci8

PHP userspace classes for Oracle to mimic the PDO interface while wrapping the oci8 functions.
PHP
7
star
29

str-begins-ends

Provides functions to test whether a string begins or ends with a certain substring.
PHP
5
star
30

rhumsaa-uuid

NO LONGER MAINTAINED. Use ramsey/uuid instead.
PHP
5
star
31

jupyter-php-docker

Dockerfile
4
star
32

MantisBT-HipChat

HipChat integration for Mantis bug tracker
PHP
3
star
33

sculpin-codeblock

A Sculpin bundle for using the ramsey/twig-codeblock extension for defining blocks of code for syntax highlighting (with Pygments) and more.
PHP
2
star
34

php-icu-testing

Dockerfile
2
star
35

http2-php-playground

PHP
2
star
36

uuid-benchmark

Benchmark tests for ramsey/uuid
PHP
2
star
37

website

My personal website and blog
PHP
2
star
38

docker-pennmush

A Docker image for PennMUSH, a MUD-style server.
Shell
2
star
39

docker-jupyter-php

Shell
2
star
40

composer-repl-lib

๐Ÿš๐Ÿ“š The library behind ramsey/composer-repl, allowing for extension of the ramsey/composer-repl Composer plugin and non-plugin use of the repl command.
PHP
2
star
41

composer-plugin-issue

This repo illustrates a problem I discovered with using Composer plugins.
1
star
42

gimmebutton

A Gimme Bar toolbar button for Firefox
Shell
1
star
43

api-toolbox

Examples used in my "A Toolbox for APIs & Integrations" presentation.
PHP
1
star
44

base

Arbitrary base conversion and encoding/decoding for all the bases that are belong to us.
PHP
1
star
45

matrix-environment

Shell
1
star