diff --git a/README.md b/README.md index b217b61..41e3446 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Any arbitrary arguments can be passed to composer by using the `args` input, how + `php_version` - Choose which version of PHP you want to use - x.y (default `latest`) (e.g. `7.4.29`, 8.2`, or any version listed on https://www.php.net/releases/index.php) + `version` - Choose which version of Composer you want to use - default `latest` (e.g. `1.x`, `1.10.26`, `2.x`, `2.2.x`, or any exact version listed on https://getcomposer.org/download/) + `memory_limit` - Sets the composer memory limit - (default _empty_) ++ `container_workdir` - Sets the aplication workdir inside container - (default /app) There are also SSH input available: `ssh_key`, `ssh_key_pub` and `ssh_domain` that are used for depending on private repositories. See below for more information on usage. @@ -113,6 +114,20 @@ jobs: version: 1 ``` +Execute composer install in a different folder +------------------------------------------- + +```yaml + - name: Install dependencies + uses: "php-actions/composer@v6" + env: + COMPOSER: "composer.json" + with: + php_version: "5.6.40" + version: "2.2" + args: "--ignore-platform-reqs --optimize-autoloader" + working_dir: "my/different/folder" +``` Including PHP Extensions ------------------------------------------- diff --git a/action.yml b/action.yml index ee3609d..a4b8332 100644 --- a/action.yml +++ b/action.yml @@ -73,6 +73,10 @@ inputs: description: "Sets the composer memory limit" required: false + container_workdir: + description: "Sets the aplication workdir inside container" + required: false + outputs: full_command: description: "The full command passed to docker to run" @@ -99,6 +103,7 @@ runs: ACTION_SSH_PORT: ${{ inputs.ssh_port }} ACTION_WORKING_DIR: ${{ inputs.working_dir }} ACTION_MEMORY_LIMIT: ${{ inputs.memory_limit }} + ACTION_CONTAINER_WORKDIR: ${{ inputs.container_workdir }} id: composer_run run: | set -e diff --git a/composer-action.bash b/composer-action.bash index fdb1a93..1ccbef7 100755 --- a/composer-action.bash +++ b/composer-action.bash @@ -1,5 +1,7 @@ #!/bin/bash set -e + +container_workdir="/app" github_action_path=$(dirname "$0") docker_tag=$(cat ./docker_tag) echo "Docker tag: $docker_tag" >> output.log 2>&1 @@ -194,6 +196,10 @@ do fi done <<<$(env) +if [ -z "$ACTION_CONTAINER_WORKDIR" ]; then + container_workdir="${ACTION_CONTAINER_WORKDIR}" +fi + echo "name=full_command::${command_string}" >> $GITHUB_OUTPUT docker run --rm \ @@ -202,7 +208,7 @@ docker run --rm \ --volume ~/.ssh:/root/.ssh \ --volume "${GITHUB_WORKSPACE}":/app \ --volume "/tmp/composer-cache":/tmp/composer-cache \ - --workdir /app \ + --workdir ${container_workdir} \ --env-file ./DOCKER_ENV \ --network host \ ${memory_limit} \