Skip to content

Commit

Permalink
fix(github): make automatic hostRules opt-in experimental (#25361)
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Oct 24, 2023
1 parent 3c8bacc commit 042b44c
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 126 deletions.
124 changes: 0 additions & 124 deletions lib/modules/platform/github/__snapshots__/index.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
Expand All @@ -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",
}
Expand All @@ -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",
}
Expand All @@ -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",
}
Expand Down
2 changes: 2 additions & 0 deletions lib/modules/platform/github/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()', () => {
Expand Down Expand Up @@ -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: {
Expand Down
5 changes: 4 additions & 1 deletion lib/modules/platform/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
{
Expand Down
5 changes: 4 additions & 1 deletion lib/modules/platform/github/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,17 @@ 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`
- `npm.pkg.github.com`
- `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 change: 1 addition & 0 deletions lib/modules/platform/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ jest.unmock('./scm');
describe('modules/platform/index', () => {
beforeEach(() => {
jest.resetModules();
process.env.RENOVATE_X_GITHUB_HOST_RULES = 'true';
});

it('validates', () => {
Expand Down

0 comments on commit 042b44c

Please sign in to comment.