-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
set insteadOf url for org-id #621
Conversation
`git config --local '${this.insteadOfKey}' '${this.insteadOfValue}'`, | ||
this.settings.nestedSubmodules | ||
) | ||
for (const insteadOfValue of this.insteadOfValues) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is for submodule config (recursive submodules)
@@ -63,7 +63,12 @@ class GitAuthHelper { | |||
|
|||
// Instead of SSH URL | |||
this.insteadOfKey = `url.${serverUrl.origin}/.insteadOf` // "origin" is SCHEME://HOSTNAME[:PORT] | |||
this.insteadOfValue = `git@${serverUrl.hostname}:` | |||
this.insteadOfValues.push(`git@${serverUrl.hostname}:`) | |||
if (this.settings.workflowOrganizationId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
register extra prefix now
@@ -118,7 +123,9 @@ class GitAuthHelper { | |||
// Configure HTTPS instead of SSH | |||
await this.git.tryConfigUnset(this.insteadOfKey, true) | |||
if (!this.settings.sshKey) { | |||
await this.git.config(this.insteadOfKey, this.insteadOfValue, true) | |||
for (const insteadOfValue of this.insteadOfValues) { | |||
await this.git.config(this.insteadOfKey, insteadOfValue, true, true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when configuring auth, now we register multiple instead-of values
this translates submodule URLs like:
[email protected]:my-org/my-submodule.git
-> https://github.com/my-org/my-submodule.git
[email protected]:my-org/my-submodule.git
-> https://github.com/my-org/my-submodule.git
]) | ||
const args: string[] = ['config', globalConfig ? '--global' : '--local'] | ||
if (add) { | ||
args.push('--add') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is required in order to add two insteadOf
URLs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try out running checkout on two separate occasions (i.e. the repo is not deleted in between runs).
/** | ||
* Gets the organization ID of the running workflow or undefined if the value cannot be loaded from the GITHUB_EVENT_PATH | ||
*/ | ||
export async function getOrganizationId(): Promise<number | undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best effort, debug log if can't load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best effort, debug log if can't load
Changes LGTM 👍 . The only thing pending to test is that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/git-auth-helper.test.ts
/** | ||
* Gets the organization ID of the running workflow or undefined if the value cannot be loaded from the GITHUB_EVENT_PATH | ||
*/ | ||
export async function getOrganizationId(): Promise<number | undefined> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
best effort, debug log if can't load
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/git-auth-helper.test.ts
🧩 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test/git-auth-helper.test.ts``
GitHub Enterprise Server can show a SSH URLs that includes organization ID, too: https://docs.github.com/en/[email protected]/organizations/managing-git-access-to-your-organizations-repositories/about-ssh-certificate-authorities#about-ssh-urls-with-ssh-certificates Follow-up: ec3a7ce (<actions#621>)
GitHub Enterprise Server can show a SSH URLs that includes organization ID, too: https://docs.github.com/en/[email protected]/organizations/managing-git-access-to-your-organizations-repositories/about-ssh-certificate-authorities#about-ssh-urls-with-ssh-certificates Follow-up: ec3a7ce 🔗 actions#621
fixes #570
When ssl certificate authentication is enabled, the clone UI suggested in the UI is like
org-<ORG_ID>@github.com:<ORG>/<REPO>.git
instead of the normal format[email protected]:<ORG>/<REPO>.git
We need to register a git config
insteadOf
url to handle the new format. Today users set the inputsubmodules: true
and the inputssh-key
is not provided, we register an insteadOf config so SSH URLs beginning with[email protected]:
are converted to HTTPS. We need to do the same thing for the new format.