From 96e2859e228ff7e98fd96076702f108005317443 Mon Sep 17 00:00:00 2001 From: Ernesto Baschny Date: Mon, 11 Jan 2021 11:04:50 +0100 Subject: [PATCH] Allow the use of Github OAuth tokens for composer install --- README.md | 4 ++++ action.yml | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/README.md b/README.md index 7293701..ade5df3 100644 --- a/README.md +++ b/README.md @@ -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` @@ -63,6 +66,7 @@ jobs: with: composer_version: ${{ env.COMPOSER_VERSION }} command: install + #github_oauth: ${{ secret.GITHUB_OAUTH }} ``` License diff --git a/action.yml b/action.yml index dc0a786..516c88f 100644 --- a/action.yml +++ b/action.yml @@ -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" @@ -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: | @@ -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