1

I am using github actions where i am storing some secrets and they will be available as environment variables. I want to access these variables form my renovate config.js files process.ENV.VARIABLE_NAME does not seem to work

There seems to be a PR that introduced this features but it is not document how it shall be used: https://github.com/renovatebot/renovate/pull/8321/files#

Here is my renovate-config.js file:

module.exports = {
  platform: 'github',
  logLevel: 'debug',
  labels: ['renovate', 'dependencies', 'automated'],
  onboarding: true,
  onboardingConfig: {
    extends: ['config:base', 'disableDependencyDashboard']
  },
  cacheDir: "/tmp/renovate",
  renovateFork: true,
  gitAuthor: "renovate <renovate@hhpv.de>",
  username: "Renovate",
  onboarding: false,
  printConfig: true,
  requireConfig: false,
  logLevel: "DEBUG",
  baseBranches: ["ecr-renovate"],
  customEnvVariables: {
    // what should i put here
  },
  hostRules: [
    {
      hostType: 'docker',
      matchHost: '123456456.dkr.ecr.eu-central-1.amazonaws.com',
      //username: process.env.AWS_ACCESS_KEY,
      //password: process.env.AWS_SECRET_KEY
    },
  ],
};
anyavacy
  • 1,618
  • 5
  • 21
  • 43

2 Answers2

2

It seems renovate does not understand environment variables inside its config file, at least I could not find a working example, too.

You can however provide parts of the renovate config as environment variables, where other environment variables can be resolved.

In my case I had to provide an access token for a private maven repository, and this is what I did in my gitlab-ci.yml:

variables:
  RENOVATE_HOST_RULES: '[{"matchHost": "https://gitlab.company.com/api/v4/groups/myprojectgroup/-/packages/maven", "token": "$CI_JOB_TOKEN"}]'

If you take a look into renovates debug log you should find an entry like this when the config is picked up:

"msg":"Adding token authentication for https://gitlab.company.com/api/v4/groups/myprojectgroup/-/packages/maven to hostRules","time":"2022-12-02T12:59:54.402Z","v":0}
schrom
  • 1,372
  • 1
  • 22
  • 36
0

You can use the customEnvVariables as follows:

customEnvVariables: {
  "CP_HOME_DIR": process.env.RENOVATE_CP_HOME_DIR
}

Then you can set RENOVATE_CP_HOME_DIR when you run renovate:

- name: Run renovate
  env:
    # add other vars here 
    RENOVATE_CP_HOME_DIR: ${{ env.CP_HOME_DIR }}
  run: npx renovate

Otherwise you can directly set the value of CP_HOME_DIR in your renovate-config.js