fix(github): make automatic hostRules opt-in experimental (#25361)

This commit is contained in:
Rhys Arkins
2023-10-24 11:34:19 +02:00
committed by GitHub
parent 3c8bacc238
commit 042b44cfbf
5 changed files with 11 additions and 126 deletions
@@ -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",
}
@@ -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: {
+4 -1
View File
@@ -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 = [
{
+4 -1
View File
@@ -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
+1
View File
@@ -11,6 +11,7 @@ jest.unmock('./scm');
describe('modules/platform/index', () => {
beforeEach(() => {
jest.resetModules();
process.env.RENOVATE_X_GITHUB_HOST_RULES = 'true';
});
it('validates', () => {