Skip to content

Commit

Permalink
Merge pull request #1 from baschny/github-oauth
Browse files Browse the repository at this point in the history
Allow the use of Github OAuth tokens for composer install
  • Loading branch information
baschny authored Jan 11, 2021
2 parents 00c0b80 + 96e2859 commit dafeda5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Input

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

* `github_oauth`: If your composer needs access to a private repo, configure the github OAuth token to use here.
For example it could come from a secret, i.e. `secrets.GITHUB_OAUTH`.

Output
------
* `composer_cache_dir`: where the composer cache is located, in case you want to use `actions/cache`
Expand Down Expand Up @@ -63,6 +66,7 @@ jobs:
with:
composer_version: ${{ env.COMPOSER_VERSION }}
command: install
#github_oauth: ${{ secret.GITHUB_OAUTH }}
```

License
Expand Down
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ inputs:
required: false
default: "--optimize-autoloader --no-progress"

github_oauth:
description: "OAuth token for accessing github private resources"
required: false
default: ""

outputs:
composer_cache_dir:
description: "Where composer created its cache"
Expand All @@ -37,6 +42,7 @@ runs:
COMPOSER_VERSION: ${{ inputs.composer_version }}
COMPOSER_COMMAND: ${{ inputs.command }}
COMPOSER_ARGS: ${{ inputs.args }}
GITHUB_OAUTH: ${{ inputs.github_oauth }}
shell: bash
id: composer_run
run: |
Expand All @@ -52,6 +58,11 @@ runs:
echo "::set-output name=composer_major_version::${DETECTED_MAJOR_VERSION}"
echo "::set-output name=composer_version::${DETECTED_VERSION}"
if [ "$GITHUB_OAUTH" ]; then
docker run --rm --volume ${RUNNER_WORKSPACE}/composer:/tmp \
composer:${COMPOSER_VERSION} config -g github-oauth.github.com $GITHUB_OAUTH
fi
case "${COMPOSER_COMMAND}" in
get_config)
exit
Expand Down

0 comments on commit dafeda5

Please sign in to comment.