Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(github): use repo url to get token #17179

Merged
merged 11 commits into from
Aug 29, 2022
Merged

Conversation

viceice
Copy link
Member

@viceice viceice commented Aug 15, 2022

Changes

  • use github repo to find token for graphql and paging
  • fix duplicate accept header value
  • fix wrong base url usage for pagination link

Context

Documentation (please check one with an [x])

  • I have updated the documentation, or
  • No documentation update is required

How I've tested my work (please tick one)

I have verified these changes via:

  • Code inspection only, or
  • Newly added/modified unit tests, or
  • No unit tests but ran on a real repository, or
  • Both unit tests + ran on a real repository

@viceice
Copy link
Member Author

viceice commented Aug 15, 2022

WDYT?

httpMock
.scope(githubApiHost, {
reqheaders: {
authorization: 'token abc',

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "token abc" is used as [authorization header](1).
httpMock
.scope('https://github.domain.com', {
reqheaders: {
authorization: 'token abc',

Check failure

Code scanning / CodeQL

Hard-coded credentials

The hard-coded value "token abc" is used as [authorization header](1).
@nabeelsaabna
Copy link
Contributor

let me test that first 🙋‍♂️
review comes after I see it working 😉

@nabeelsaabna
Copy link
Contributor

can I use hostType=go or it's only for hostType=github ?

@viceice
Copy link
Member Author

viceice commented Aug 15, 2022

should maybe also work for go

@nabeelsaabna
Copy link
Contributor

nabeelsaabna commented Aug 15, 2022

works like a charm 🎉

Got 4 open PRs :

  1. Go version upgrade
  2. private repo on same org
  3. private repo on different org
  4. private repo on gitlab

I need both in the config:

  1. "matchHost": "https://gitlab.com/nabeelsaabna" with type Go or github
  2. "matchHost": "https://api.github.com/repos/nabeelsaabna" with type github

any other combination does not work (i'm OK with that)

{
	"$schema": "https://docs.renovatebot.com/renovate-schema.json",
	"dependencyDashboard": true,
	"hostRules": [
		{
			"matchHost": "https://gitlab.com",
			"token": "glpat-token_for_different_git_platform",
			"hostType": "gitlab"
		},
		{
			"matchHost": "https://github.com/nabeelsaabna",
			"token": "ghp_token_for_different_org",
			"hostType": "go"
		},
		{
			"matchHost": "https://api.github.com/repos/nabeelsaabna",
			"token": "ghp_token_for_different_org",
			"hostType": "github"
		}	
	],
	"customEnvVariables": {
		"GOPRIVATE": "github.com/nabeelsaabna,github.com/nabeelys,gitlab.com/nabeelsaabna",
		"GONOSUMDB": "github.com/nabeelsaabna,github.com/nabeelys,gitlab.com/nabeelsaabna",
		"GONOPROXY": "github.com/nabeelsaabna,github.com/nabeelys,gitlab.com/nabeelsaabna"
	},
	"postUpdateOptions": ["gomodTidy"]
}

@viceice
Copy link
Member Author

viceice commented Aug 15, 2022

would the API url for the hostrules be expected? can somebody give some advice where we should document this feature?

@rarkins
Copy link
Collaborator

rarkins commented Aug 16, 2022

If it's tightly related to Go then let's add it to https://github.com/renovatebot/renovate/blob/main/lib/modules/manager/gomod/readme.md at least

@viceice
Copy link
Member Author

viceice commented Aug 16, 2022

If it's tightly related to Go then let's add it to https://github.com/renovatebot/renovate/blob/main/lib/modules/manager/gomod/readme.md at least

No, it's more relevant for datasources, so you can now override the token for a github repository for github-releases without interferring the app token

@rarkins
Copy link
Collaborator

rarkins commented Aug 17, 2022

@viceice viceice requested a review from HonkingGoose August 24, 2022 08:54
@viceice viceice marked this pull request as ready for review August 24, 2022 08:54
@viceice
Copy link
Member Author

viceice commented Aug 24, 2022

ready for review

@viceice viceice requested a review from rarkins August 24, 2022 08:58
Co-authored-by: Rhys Arkins <[email protected]>
Co-authored-by: HonkingGoose <[email protected]>
@rarkins rarkins enabled auto-merge (squash) August 29, 2022 07:25
@rarkins rarkins merged commit 6dd4ea3 into main Aug 29, 2022
@rarkins rarkins deleted the feat/github/repo-url-auth branch August 29, 2022 07:37
@renovate-release
Copy link
Collaborator

🎉 This PR is included in version 32.182.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GitHub API Pagination Link headers lead to unexpected paths
5 participants