Skip to content

Commit 2ec65b6

Browse files
author
Greg Bowler
authored
Merge pull request #103 from vakaman/add-app-folder
Add app folder
2 parents 3cfffbd + 1d79c12 commit 2ec65b6

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

README.md

+15
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ Any arbitrary arguments can be passed to composer by using the `args` input, how
6969
+ `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)
7070
+ `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/)
7171
+ `memory_limit` - Sets the composer memory limit - (default _empty_)
72+
+ `container_workdir` - Sets the aplication workdir inside container - (default /app)
7273

7374
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.
7475

@@ -113,6 +114,20 @@ jobs:
113114
version: 1
114115
```
115116

117+
Execute composer install in a different folder
118+
-------------------------------------------
119+
120+
```yaml
121+
- name: Install dependencies
122+
uses: "php-actions/composer@v6"
123+
env:
124+
COMPOSER: "composer.json"
125+
with:
126+
php_version: "5.6.40"
127+
version: "2.2"
128+
args: "--ignore-platform-reqs --optimize-autoloader"
129+
working_dir: "my/different/folder"
130+
```
116131

117132
Including PHP Extensions
118133
-------------------------------------------

action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ inputs:
7373
description: "Sets the composer memory limit"
7474
required: false
7575

76+
container_workdir:
77+
description: "Sets the aplication workdir inside container"
78+
required: false
79+
7680
outputs:
7781
full_command:
7882
description: "The full command passed to docker to run"
@@ -99,6 +103,7 @@ runs:
99103
ACTION_SSH_PORT: ${{ inputs.ssh_port }}
100104
ACTION_WORKING_DIR: ${{ inputs.working_dir }}
101105
ACTION_MEMORY_LIMIT: ${{ inputs.memory_limit }}
106+
ACTION_CONTAINER_WORKDIR: ${{ inputs.container_workdir }}
102107
id: composer_run
103108
run: |
104109
set -e

composer-action.bash

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/bin/bash
22
set -e
3+
4+
container_workdir="/app"
35
github_action_path=$(dirname "$0")
46
docker_tag=$(cat ./docker_tag)
57
echo "Docker tag: $docker_tag" >> output.log 2>&1
@@ -194,6 +196,10 @@ do
194196
fi
195197
done <<<$(env)
196198

199+
if [ -z "$ACTION_CONTAINER_WORKDIR" ]; then
200+
container_workdir="${ACTION_CONTAINER_WORKDIR}"
201+
fi
202+
197203
echo "name=full_command::${command_string}" >> $GITHUB_OUTPUT
198204

199205
docker run --rm \
@@ -202,7 +208,7 @@ docker run --rm \
202208
--volume ~/.ssh:/root/.ssh \
203209
--volume "${GITHUB_WORKSPACE}":/app \
204210
--volume "/tmp/composer-cache":/tmp/composer-cache \
205-
--workdir /app \
211+
--workdir ${container_workdir} \
206212
--env-file ./DOCKER_ENV \
207213
--network host \
208214
${memory_limit} \

0 commit comments

Comments
 (0)