Using GitHub secrets for adding hostRules.token for Private Terraform Cloud Module #833
-
Hi, I am using the name: Renovate-terraform
on:
schedule:
- cron: '0 */6 * * *'
workflow_dispatch:
jobs:
renovate:
runs-on: ubuntu-latest
steps:
- name: Get token
id: get_token
uses: getsentry/action-github-app-token@v3
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/[email protected]
- name: Self-hosted Renovate
uses: renovatebot/[email protected]
with:
configurationFile: terraform-renovate.json
token: '${{ steps.get_token.outputs.token }}'
env:
LOG_LEVEL: 'debug'
RENOVATE_DETECT_HOST_RULES_FROM_ENV: true
TERRAFORM_CLOUD_TOKEN: ${{ secrets.TERRAFORM_CLOUD_TOKEN }} My {
"repositories": [
"XXXX/ent-app-aks-infrastructure"
],
"printConfig": false,
"allowCustomCrateRegistries": true,
"allowScripts": true,
"exposeAllEnv": true,
"assignAutomerge": false,
"automerge": false,
"branchPrefix": "renovate/",
"platform": "github",
"forkProcessing": "disabled",
"assigneesFromCodeOwners": true,
"prHourlyLimit": 0,
"timezone": "Europe/Oslo",
"dependencyDashboard": false,
"extends": ["config:recommended", ":disableDependencyDashboard"],
"kubernetes": {"enabled": true, "fileMatch": ["\\.ya?ml$"]},
"packageRules": [
{"matchManagers": ["terraform"], "groupName": "terraform"},
{"matchManagers": ["kubernetes"], "groupName": "kubernetes"}
],
"vulnerabilityAlerts": {"addLabels": ["security"]},
"username": "Renovate-bot-XXXXXX[bot]",
"gitAuthor": "Renovate-bot-XXXXXX <136432898+renovate-bot-XXXXXX[bot]@users.noreply.github.com>",
"hostRules": [
{
"hostType": "terraform-module",
"matchHost": "app.terraform.io",
"token": "{{ env.TERRAFORM_CLOUD_TOKEN }}"
}
]
} When I run the above config, it seems like the token is added to the setup, but it fails when it is trying to fetch the module:
When I add the token value directly in the config like
it works perfectly. I wonder if there is a way for me to fetch the token for Terraform Cloud from a GitHub secret? It could be something I don't really understand here and would love some pointers in the right direction if possible. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Renovate does not automatically populate the contents of |
Beta Was this translation helpful? Give feedback.
Renovate does not automatically populate the contents of
env
forrenovate.json
as this would be a security risk. You'd be better to create your hostRules in a config.js file which is admin-controlled and allowed to read env using process.env.X