composer.json based on environment
How do I... ?
Use a different composer.json, e.g. composer.gh-actions.json (in the root directory) instead of defining a working-directory to another directory.
Example code
E.g.
- name: Install composer dependencies uses: ramsey/composer-install@v3 with: working-composer: 'composer.gh-actions.json'
I believe the COMPOSER environment variable lets you do this, as documented here. However, the filename composer.json seems to be hardcoded here in this action.
A workaround might be to add zero-byte composer.json and composer.lock files to your repo to satisfy this script's looking for them... not sure though.
Yes, I've read Composer's doc and seen the hardcoded composer.json file, I planned to open a PR if I didn't get a solution soon.
Could you elaborate on the zero-byte composer.json and composer.lock files?
@badasukerubin This GitHub action tests for the existence of composer.json and composer.lock. It doesn't actually use these filenames when invoking composer (composer uses the environment variable COMPOSER), but not having these files in existence causes the action to have problems.
I have not tested this (I'm not the script author, just an interested person). But it looks like so long as these files exist, this action will be happy. So if you just make placeholder files with these names, this action may work for now. It still seems like a bug, but this may work around the problem.
I'd accept a PR that allows you to customize the name of the Composer file.
I'm working on a PR
Opened a PR: #261 cc @ramsey