From cd4dee329720030349b278460f2f6ff8ddaca4c4 Mon Sep 17 00:00:00 2001 From: Jeroen de Bruijn Date: Thu, 19 Mar 2020 23:00:43 +0100 Subject: [PATCH] feat: add token input and account for Renovate WORKDIR --- .github/workflows/example-basic.yml | 5 +++-- action.yml | 8 ++++++++ src/entrypoint.sh | 17 ++++++++++++----- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/example-basic.yml b/.github/workflows/example-basic.yml index f19f3704..7d979d3e 100644 --- a/.github/workflows/example-basic.yml +++ b/.github/workflows/example-basic.yml @@ -1,11 +1,11 @@ -name: Basic example +name: Example on: push: branches: - master pull_request: jobs: - basic-example: + example: runs-on: ubuntu-latest steps: - name: Checkout @@ -14,3 +14,4 @@ jobs: uses: ./ with: configurationFile: 'test/config.js' + token: ${{ secrets.RENOVATE_TOKEN }} diff --git a/action.yml b/action.yml index 98a711bf..1215d99e 100644 --- a/action.yml +++ b/action.yml @@ -6,6 +6,14 @@ inputs: description: 'Renovate configuration file' required: false default: 'src/config.js' + token: + description: | + Personal access token that Renovate should use. This should be configured + using a GitHub secret. + required: true runs: using: 'docker' image: 'src/Dockerfile' + args: + - ${{ inputs.configurationFile }} + - ${{ inputs.token }} diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 74e5f2b8..9b58b11b 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -3,6 +3,8 @@ # Entrypoint for Docker. readonly CONFIGURATION_FILE="${1}" +readonly TOKEN="${2}" + readonly CONFIGURATION_PATH="${GITHUB_WORKSPACE}/${CONFIGURATION_FILE}" if [[ ! -f "${CONFIGURATION_PATH}" ]]; then @@ -10,12 +12,17 @@ if [[ ! -f "${CONFIGURATION_PATH}" ]]; then exit 1 fi -cp "${CONFIGURATION_PATH}" '/usr/src/app/config.js' +readonly WORKDIR='/usr/src/app' +# Account for the WORKDIR entry of the renovate/renovate Docker container. See +# the followling link for this entry. +# https://github.com/renovatebot/renovate/blob/19.175.3/Dockerfile#L14 +cd "${WORKDIR}" || { echo "ERROR: Couldn't cd to ${WORKDIR}" 1>&2; exit 1; } + +cp "${CONFIGURATION_PATH}" './config.js' # Run Renovate. # -# This mimics the original entrypoint of the renovate/renovate Docker container. -# See the following link for this entrypoint in the renovate/renovate Docker -# container. +# Mimic the original ENTRYPOINT of the renovate/renovate Docker container. See +# the following link for this entry. # https://github.com/renovatebot/renovate/blob/19.175.3/Dockerfile#L220 -node /usr/src/app/dist/renovate.js +RENOVATE_TOKEN="${TOKEN}" node /usr/src/app/dist/renovate.js