You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+30
Original file line number
Diff line number
Diff line change
@@ -7,6 +7,8 @@ Composer is a tool for dependency management in PHP. It allows you to declare th
7
7
8
8
If you are running tests like [PHPUnit][php-actions-phpunit], [phpspec][php-actions-phpspec] or [Behat][php-actions-behat] in your Github actions, chances are you will need to install your project's dependencies using Composer.
9
9
10
+
An example repository has been created at https://github.com/php-actions/example-composer to show how to use this action in a real project. The repository also depends on a private dependency and uses SSH keys for authentication.
11
+
10
12
Usage
11
13
-----
12
14
@@ -58,6 +60,8 @@ Any arbitrary arguments can be passed to composer by using the `args` input, how
58
60
+ `quiet` - Whether to suppress all messages - yes / no (default no)
59
61
+ `args` - Optional arguments to pass - no constraints (default _empty_)
60
62
63
+
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.
64
+
61
65
Example of a yaml config that wants to see suggestions and does not want to install dev packages, and passes the `--profile` and `--ignore-platform-reqs` arguments:
62
66
63
67
```yaml
@@ -119,11 +123,37 @@ jobs:
119
123
120
124
In the example above, the "key" is passed to the Cache action that consists of a hash of the composer.lock file. This means that as long as the contents of composer.lock doesn't change between workflows, the Composer cache directory will be persisted between workflows.
121
125
126
+
Installing private repositories
127
+
-------------------------------
128
+
129
+
To install from a private repository, SSH authentication must be used. Generate an SSH key pair for this purpose and add it to your private repository's configuration, preferable with only read-only privileges. On Github for instance, this can be done by using [deploy keys][deploy-keys].
130
+
131
+
Add the key pair to your project using [Github Secrets][secrets], and pass them into the `php-actions/composer` action by using the `ssh_key` and `ssh_key_pub` inputs. If your private repository is stored on another server than github.com, you also need to pass the domain via `ssh_domain`.
132
+
133
+
Example yaml, showing how to pass secrets:
134
+
135
+
```yaml
136
+
jobs:
137
+
build:
138
+
139
+
...
140
+
141
+
- name: Install dependencies
142
+
uses: php-actions/composer@v2
143
+
with:
144
+
ssh_key: ${{ secrets.ssh_key }}
145
+
ssh_key_pub: ${{ secrets.ssh_key_pub }}
146
+
```
147
+
148
+
There is an example repository available for reference at https://github.com/php-actions/example-composer that uses a private dependency. Check it out for a live working project.
149
+
122
150
***
123
151
124
152
If you found this repository helpful, please consider [sponsoring the developer][sponsor].
0 commit comments