diff --git a/README.md b/README.md index 5b7b8955..dd6d21d9 100644 --- a/README.md +++ b/README.md @@ -437,6 +437,12 @@ For example if you wish to pass through some credentials for a [host rule](https }; ``` +### User agent + +By default, the Action sets [`RENOVATE_USER_AGENT`](https://docs.renovatebot.com/self-hosted-configuration/#useragent) to `Renovate/{{renovateVersion}} (https://github.com/renovatebot/github-action)`, so that operators of registries can identify traffic coming from this Action. + +To override it, set the `RENOVATE_USER_AGENT` environment variable on the Action step. + ### Passing other environment variables There are two ways to pass additional variables through to the Renovate container: diff --git a/src/renovate.ts b/src/renovate.ts index 47dc0381..28527cdc 100644 --- a/src/renovate.ts +++ b/src/renovate.ts @@ -6,6 +6,9 @@ import { Input } from './input'; export class Renovate { static dockerGroupRegex = /^docker:x:(?[1-9][0-9]*):/m; + private static readonly userAgentKey = 'RENOVATE_USER_AGENT'; + private static readonly defaultUserAgent = + 'Renovate/{{renovateVersion}} (https://github.com/renovatebot/github-action)'; private configFileMountDir = '/github-action'; private docker: Docker; @@ -33,6 +36,10 @@ export class Renovate { .map((e) => `--env ${e.key}`) .concat([`--env ${this.input.token.key}=${this.input.token.value} --env FORCE_COLOR=3`]); + if (!this.input.toEnvironmentVariables().some((e) => e.key === Renovate.userAgentKey)) { + dockerArguments.push(`--env "${Renovate.userAgentKey}=${Renovate.defaultUserAgent}"`); + } + const configurationFile = this.input.configurationFile(); if (configurationFile !== null) { const baseName = path.basename(configurationFile.value);