From d9d07aae8e5e00e0f4787bca8ae4fd9126dad4a5 Mon Sep 17 00:00:00 2001 From: Maicol Kaiser Date: Fri, 7 Jul 2023 16:25:48 -0300 Subject: [PATCH 1/5] feat: add app folder --- action.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/action.yml b/action.yml index ee3609d..639f3ac 100644 --- a/action.yml +++ b/action.yml @@ -73,6 +73,10 @@ inputs: description: "Sets the composer memory limit" required: false + app_folder: + description: "Sets the aplication folder" + 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_APP_FOLDER: ${{ inputs.app_folder }} id: composer_run run: | set -e From 1d8a288abe689a7d136c6b811d33d7e548c6dff1 Mon Sep 17 00:00:00 2001 From: Maicol Kaiser Date: Fri, 7 Jul 2023 16:26:04 -0300 Subject: [PATCH 2/5] feat: add app folder when env exists --- composer-action.bash | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/composer-action.bash b/composer-action.bash index fdb1a93..77f53b2 100755 --- a/composer-action.bash +++ b/composer-action.bash @@ -1,5 +1,7 @@ #!/bin/bash set -e + +app_folder="/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_APP_FOLDER" ]; then + app_folder="${ACTION_APP_FOLDER}" +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 ${app_folder} \ --env-file ./DOCKER_ENV \ --network host \ ${memory_limit} \ From 280bb0248446e9d52000a3b9977084d1d37ba3ae Mon Sep 17 00:00:00 2001 From: Maicol Kaiser Date: Fri, 7 Jul 2023 16:26:20 -0300 Subject: [PATCH 3/5] feat: update readme to include example of app_folder --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index eed2551..8311fc6 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.10`, `2.3`, `2.5.4`) + `memory_limit` - Sets the composer memory limit - (default _empty_) ++ `app_folder` - Sets the aplication folder - (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. From cb274c54eb15b0f18260025d600f27377a8e3339 Mon Sep 17 00:00:00 2001 From: Maicol Kaiser Date: Sat, 8 Jul 2023 09:18:22 -0300 Subject: [PATCH 4/5] refact: replace app_folder to container_workdir --- README.md | 2 +- action.yml | 6 +++--- composer-action.bash | 8 ++++---- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 8311fc6..520c66a 100644 --- a/README.md +++ b/README.md @@ -69,7 +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.10`, `2.3`, `2.5.4`) + `memory_limit` - Sets the composer memory limit - (default _empty_) -+ `app_folder` - Sets the aplication folder - (default /app) ++ `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. diff --git a/action.yml b/action.yml index 639f3ac..a4b8332 100644 --- a/action.yml +++ b/action.yml @@ -73,8 +73,8 @@ inputs: description: "Sets the composer memory limit" required: false - app_folder: - description: "Sets the aplication folder" + container_workdir: + description: "Sets the aplication workdir inside container" required: false outputs: @@ -103,7 +103,7 @@ runs: ACTION_SSH_PORT: ${{ inputs.ssh_port }} ACTION_WORKING_DIR: ${{ inputs.working_dir }} ACTION_MEMORY_LIMIT: ${{ inputs.memory_limit }} - ACTION_APP_FOLDER: ${{ inputs.app_folder }} + ACTION_CONTAINER_WORKDIR: ${{ inputs.container_workdir }} id: composer_run run: | set -e diff --git a/composer-action.bash b/composer-action.bash index 77f53b2..1ccbef7 100755 --- a/composer-action.bash +++ b/composer-action.bash @@ -1,7 +1,7 @@ #!/bin/bash set -e -app_folder="/app" +container_workdir="/app" github_action_path=$(dirname "$0") docker_tag=$(cat ./docker_tag) echo "Docker tag: $docker_tag" >> output.log 2>&1 @@ -196,8 +196,8 @@ do fi done <<<$(env) -if [ -z "$ACTION_APP_FOLDER" ]; then - app_folder="${ACTION_APP_FOLDER}" +if [ -z "$ACTION_CONTAINER_WORKDIR" ]; then + container_workdir="${ACTION_CONTAINER_WORKDIR}" fi echo "name=full_command::${command_string}" >> $GITHUB_OUTPUT @@ -208,7 +208,7 @@ docker run --rm \ --volume ~/.ssh:/root/.ssh \ --volume "${GITHUB_WORKSPACE}":/app \ --volume "/tmp/composer-cache":/tmp/composer-cache \ - --workdir ${app_folder} \ + --workdir ${container_workdir} \ --env-file ./DOCKER_ENV \ --network host \ ${memory_limit} \ From 1d79c12e8d454cf970f5815c42b0464a493b634f Mon Sep 17 00:00:00 2001 From: Maicol Kaiser Date: Sat, 8 Jul 2023 09:23:22 -0300 Subject: [PATCH 5/5] feat: add reference to execute installation in a different folder --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 520c66a..649a316 100644 --- a/README.md +++ b/README.md @@ -114,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 -------------------------------------------