diff --git a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap index 46adade588864cd012ba6a0c7c59c10e93571a58..9bbc6ed9a5e14e70751318d56f3b45ad2c4a7b4f 100644 --- a/lib/modules/platform/github/__snapshots__/index.spec.ts.snap +++ b/lib/modules/platform/github/__snapshots__/index.spec.ts.snap @@ -31,37 +31,6 @@ exports[`modules/platform/github/index initPlatform() should support default end { "endpoint": "https://api.github.com/", "gitAuthor": undefined, - "hostRules": [ - { - "hostType": "docker", - "matchHost": "ghcr.io", - "password": "123test", - "username": "USERNAME", - }, - { - "hostType": "npm", - "matchHost": "npm.pkg.github.com", - "token": "123test", - }, - { - "hostType": "rubygems", - "matchHost": "rubygems.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "maven", - "matchHost": "maven.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "nuget", - "matchHost": "nuget.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - ], "renovateUsername": "renovate-bot", "token": "123test", } @@ -71,37 +40,6 @@ exports[`modules/platform/github/index initPlatform() should support default end { "endpoint": "https://api.github.com/", "gitAuthor": undefined, - "hostRules": [ - { - "hostType": "docker", - "matchHost": "ghcr.io", - "password": "123test", - "username": "USERNAME", - }, - { - "hostType": "npm", - "matchHost": "npm.pkg.github.com", - "token": "123test", - }, - { - "hostType": "rubygems", - "matchHost": "rubygems.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "maven", - "matchHost": "maven.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "nuget", - "matchHost": "nuget.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - ], "renovateUsername": "renovate-bot", "token": "123test", } @@ -111,37 +49,6 @@ exports[`modules/platform/github/index initPlatform() should support default end { "endpoint": "https://api.github.com/", "gitAuthor": "undefined <user@domain.com>", - "hostRules": [ - { - "hostType": "docker", - "matchHost": "ghcr.io", - "password": "123test", - "username": "USERNAME", - }, - { - "hostType": "npm", - "matchHost": "npm.pkg.github.com", - "token": "123test", - }, - { - "hostType": "rubygems", - "matchHost": "rubygems.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "maven", - "matchHost": "maven.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "nuget", - "matchHost": "nuget.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - ], "renovateUsername": "renovate-bot", "token": "123test", } @@ -151,37 +58,6 @@ exports[`modules/platform/github/index initPlatform() should support gitAuthor a { "endpoint": "https://api.github.com/", "gitAuthor": "renovate@whitesourcesoftware.com", - "hostRules": [ - { - "hostType": "docker", - "matchHost": "ghcr.io", - "password": "123test", - "username": "USERNAME", - }, - { - "hostType": "npm", - "matchHost": "npm.pkg.github.com", - "token": "123test", - }, - { - "hostType": "rubygems", - "matchHost": "rubygems.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "maven", - "matchHost": "maven.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - { - "hostType": "nuget", - "matchHost": "nuget.pkg.github.com", - "password": "123test", - "username": "renovate-bot", - }, - ], "renovateUsername": "renovate-bot", "token": "123test", } diff --git a/lib/modules/platform/github/index.spec.ts b/lib/modules/platform/github/index.spec.ts index 2401d7895d7dce53b5b3e0de89d1c7fed00dac3d..1ad9921a51d3a6ee3c8199b6fad01434afaa6c52 100644 --- a/lib/modules/platform/github/index.spec.ts +++ b/lib/modules/platform/github/index.spec.ts @@ -48,6 +48,7 @@ describe('modules/platform/github/index', () => { const repoCache = repository.getCache(); delete repoCache.platform; + delete process.env.RENOVATE_X_GITHUB_HOST_RULES; }); describe('initPlatform()', () => { @@ -162,6 +163,7 @@ describe('modules/platform/github/index', () => { }); it('should autodetect email/user on default endpoint with GitHub App', async () => { + process.env.RENOVATE_X_GITHUB_HOST_RULES = 'true'; httpMock .scope(githubApiHost, { reqheaders: { diff --git a/lib/modules/platform/github/index.ts b/lib/modules/platform/github/index.ts index abf9d94fd658cc161c91cf5d4d1ac6ca7e07b7dd..bdc39b5457ca989d9222113835957ffd85b6e1c3 100644 --- a/lib/modules/platform/github/index.ts +++ b/lib/modules/platform/github/index.ts @@ -204,7 +204,10 @@ export async function initPlatform({ renovateUsername, token, }; - if (platformResult.endpoint === 'https://api.github.com/') { + if ( + process.env.RENOVATE_X_GITHUB_HOST_RULES && + platformResult.endpoint === 'https://api.github.com/' + ) { logger.debug('Adding GitHub token as GHCR password'); platformResult.hostRules = [ { diff --git a/lib/modules/platform/github/readme.md b/lib/modules/platform/github/readme.md index 74846bac469d00b9c63a20911dfd5bc8e3d40ed0..41d134bb4a69862f6826c07ac573db23f328b763 100644 --- a/lib/modules/platform/github/readme.md +++ b/lib/modules/platform/github/readme.md @@ -87,7 +87,7 @@ A way to get the user id of a GitHub app is to [query the user API](https://docs ## Package Registry Credentials -When Renovate runs against repositories on `github.com`, it automatically provisions `hostRules` for these GitHub Packages registries using the platform token: +When Renovate runs against repositories on `github.com`, and the environment variable `RENOVATE_X_GITHUB_HOST_RULES` is set, then Renovate automatically provisions `hostRules` for these GitHub Packages registries using the platform token: - `ghcr.io` - `maven.pkg.github.com` @@ -95,6 +95,9 @@ When Renovate runs against repositories on `github.com`, it automatically provis - `nuget.pkg.github.com` - `rubygems.pkg.github.com` +<!-- prettier-ignore --> +!!! warning Users have reported that this feature is not working correctly, so it has been reverted to experimental mode. + ## Features awaiting implementation - The `automergeStrategy` configuration option has not been implemented for this platform, and all values behave as if the value `auto` was used. Renovate will use the merge strategy configured in the GitHub repository itself, and this cannot be overridden yet diff --git a/lib/modules/platform/index.spec.ts b/lib/modules/platform/index.spec.ts index 9e8093f14179ba63d6e360cc850aeff7a197d716..fa5587877db6ce88ae1c8592612bf4957102cbdf 100644 --- a/lib/modules/platform/index.spec.ts +++ b/lib/modules/platform/index.spec.ts @@ -11,6 +11,7 @@ jest.unmock('./scm'); describe('modules/platform/index', () => { beforeEach(() => { jest.resetModules(); + process.env.RENOVATE_X_GITHUB_HOST_RULES = 'true'; }); it('validates', () => {