Skip to content

Commit c3a2428

Browse files
author
Greg Bowler
committed
Update readme with secrets
1 parent 13b5f67 commit c3a2428

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

README.md

+30
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ Composer is a tool for dependency management in PHP. It allows you to declare th
77

88
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.
99

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+
1012
Usage
1113
-----
1214

@@ -58,6 +60,8 @@ Any arbitrary arguments can be passed to composer by using the `args` input, how
5860
+ `quiet` - Whether to suppress all messages - yes / no (default no)
5961
+ `args` - Optional arguments to pass - no constraints (default _empty_)
6062

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+
6165
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:
6266

6367
```yaml
@@ -119,11 +123,37 @@ jobs:
119123

120124
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.
121125

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+
122150
***
123151

124152
If you found this repository helpful, please consider [sponsoring the developer][sponsor].
125153

126154
[php-actions-phpunit]: https://github.com/marketplace/actions/phpunit-php-actions
127155
[php-actions-phpspec]: https://github.com/marketplace/actions/phpspec-php-actions
128156
[php-actions-behat]: https://github.com/marketplace/actions/behat-php-actions
157+
[deploy-keys]: https://docs.github.com/en/developers/overview/managing-deploy-keys
158+
[secrets]: https://docs.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets
129159
[sponsor]: https://github.com/sponsors/g105b

action.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ inputs:
4444
required: false
4545

4646
ssh_domain:
47-
description: The domain to gether SSH public keys for (automatic for github.com, gitlab.com, bitbucket.org)
47+
description: The domain to gather SSH public keys for (automatic for github.com, gitlab.com, bitbucket.org)
4848
required: false
4949

5050
outputs:

0 commit comments

Comments
 (0)