Skip to content

Commit 96e2859

Browse files
committed
Allow the use of Github OAuth tokens for composer install
1 parent 00c0b80 commit 96e2859

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Input
1616

1717
* `args`: Other command line arguments to pass to composer, defaults to `--optimize-autoloader --no-progress`
1818

19+
* `github_oauth`: If your composer needs access to a private repo, configure the github OAuth token to use here.
20+
For example it could come from a secret, i.e. `secrets.GITHUB_OAUTH`.
21+
1922
Output
2023
------
2124
* `composer_cache_dir`: where the composer cache is located, in case you want to use `actions/cache`
@@ -63,6 +66,7 @@ jobs:
6366
with:
6467
composer_version: ${{ env.COMPOSER_VERSION }}
6568
command: install
69+
#github_oauth: ${{ secret.GITHUB_OAUTH }}
6670
```
6771

6872
License

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ inputs:
1717
required: false
1818
default: "--optimize-autoloader --no-progress"
1919

20+
github_oauth:
21+
description: "OAuth token for accessing github private resources"
22+
required: false
23+
default: ""
24+
2025
outputs:
2126
composer_cache_dir:
2227
description: "Where composer created its cache"
@@ -37,6 +42,7 @@ runs:
3742
COMPOSER_VERSION: ${{ inputs.composer_version }}
3843
COMPOSER_COMMAND: ${{ inputs.command }}
3944
COMPOSER_ARGS: ${{ inputs.args }}
45+
GITHUB_OAUTH: ${{ inputs.github_oauth }}
4046
shell: bash
4147
id: composer_run
4248
run: |
@@ -52,6 +58,11 @@ runs:
5258
echo "::set-output name=composer_major_version::${DETECTED_MAJOR_VERSION}"
5359
echo "::set-output name=composer_version::${DETECTED_VERSION}"
5460
61+
if [ "$GITHUB_OAUTH" ]; then
62+
docker run --rm --volume ${RUNNER_WORKSPACE}/composer:/tmp \
63+
composer:${COMPOSER_VERSION} config -g github-oauth.github.com $GITHUB_OAUTH
64+
fi
65+
5566
case "${COMPOSER_COMMAND}" in
5667
get_config)
5768
exit

0 commit comments

Comments
 (0)