From 300c83c1736241b7daac3aedca5e7b34109fdca6 Mon Sep 17 00:00:00 2001 From: Mike Ryan Date: Fri, 11 Sep 2026 04:02:37 -0500 Subject: [PATCH] feat: support forwarding list of env vars to renovate container (#1032) --- README.md | 36 ++++++++++++++++++++++++++++++++++-- action.yml | 6 +++++- src/input.ts | 14 ++++++++++++-- 3 files changed, 51 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 250d6689..75cacaff 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,7 @@ GitHub Action to run Renovate self-hosted. - [Badges](#badges) - [Options](#options) + - [`additional-env-list`](#additional-env-list) - [`configurationFile`](#configurationfile) - [`docker-cmd-file`](#docker-cmd-file) - [`docker-network`](#docker-network) @@ -44,6 +45,11 @@ Options can be passed using the inputs of this action or the corresponding envir When both are passed, the input takes precedence over the environment variable. For the available environment variables, see the Renovate [Self-Hosted Configuration](https://docs.renovatebot.com/self-hosted-configuration/) docs. +### `additional-env-list` + +A newline-separated list of environment variable names to pass through to the Renovate container, in addition to those already matched by [`env-regex`](#env-regex). +See [Passing other environment variables](#passing-other-environment-variables) section for more details. + ### `configurationFile` Configuration file to configure Renovate ("global" config) in JavaScript or JSON format. @@ -416,9 +422,35 @@ For example if you wish to pass through some credentials for a [host rule](https ### Passing other environment variables -If you want to pass other variables to the Docker container use the `env-regex` input to override the regular expression that is used to allow environment variables. +There are two ways to pass additional variables through to the Renovate container: -In your workflow pass the environment variable and whitelist it by specifying the `env-regex`: +1. **Recommended:** use [`additional-env-list`](#additional-env-list) to list the names of the variables you want forwarded. This keeps the action's default `env-regex` in effect, so you'll continue to receive any future additions to the default allow-list. Variable names that are not present in the environment are silently ignored. +2. Override [`env-regex`](#env-regex) with a custom regular expression. This gives you full control but also full ownership: if the action's default pattern changes, your override will not pick up those changes, and a typo in the regex can silently drop variables (including `RENOVATE_*` ones). + +Example using `additional-env-list` (recommended): + +```yml +.... +jobs: + renovate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v6.0.3 + - name: Self-hosted Renovate + uses: renovatebot/github-action@v46.1.16 + with: + configurationFile: example/renovate-config.js + token: ${{ secrets.RENOVATE_TOKEN }} + additional-env-list: | + AWS_TOKEN + MY_OTHER_SECRET + env: + AWS_TOKEN: ${{ secrets.AWS_TOKEN }} + MY_OTHER_SECRET: ${{ secrets.MY_OTHER_SECRET }} +``` + +Example using `env-regex` (full override): ```yml .... diff --git a/action.yml b/action.yml index 26b12511..3e7c2c8e 100644 --- a/action.yml +++ b/action.yml @@ -18,9 +18,13 @@ inputs: required: false env-regex: description: | - Override the environment variables which will be passsed into the renovate container. + Override the environment variables which will be passed into the renovate container. Defaults to `^(?:RENOVATE_\\w+|LOG_LEVEL|GITHUB_COM_TOKEN|NODE_OPTIONS|NO_COLOR|(?:HTTPS?|NO)_PROXY|(?:https?|no)_proxy)$` required: false + additional-env-list: + description: | + A newline-separated list of environment variable names to pass through to the Renovate container, in addition to those already matched by env-regex. + required: false renovate-version: description: | Renovate version to use. diff --git a/src/input.ts b/src/input.ts index ee988b6c..1497edef 100644 --- a/src/input.ts +++ b/src/input.ts @@ -1,4 +1,4 @@ -import { getInput } from '@actions/core'; +import { getInput, getMultilineInput, warning } from '@actions/core'; import path from 'node:path'; export interface EnvironmentVariable { @@ -31,11 +31,21 @@ export class Input { const envRegex = envRegexInput ? new RegExp(envRegexInput) : this.options.envRegex; + const additionalEnvVarNames = getMultilineInput('additional-env-list'); this._environmentVariables = new Map( Object.entries(process.env) - .filter(([key]) => envRegex.test(key)) + .filter( + ([key]) => envRegex.test(key) || additionalEnvVarNames.includes(key), + ) .filter((pair): pair is [string, string] => pair[1] !== undefined), ); + for (const name of additionalEnvVarNames) { + if (!this._environmentVariables.has(name)) { + warning( + `Environment variable '${name}' listed in 'additional-env-list' was not found in the parent process environment; it will not be passed to the renovate container.`, + ); + } + } this.token = this.get( this.options.token.input,