#68 Option 2: Use lower case key

This commit is contained in:
Sean Killeen 2021-03-17 12:01:00 -04:00 committed by GitHub
parent 4b6f4eb000
commit 18547f3cc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -50,16 +50,17 @@ try {
console.log('Configuring deployment key(s)');
child_process.execFileSync(sshAdd, ['-L']).toString().split(/\r?\n/).forEach(function(key) {
const parts = key.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/);
var lowerCaseKey = key.ToLowerCase();
const parts = lowerCaseKey.match(/\bgithub\.com[:/]([_.a-z0-9-]+\/[_.a-z0-9-]+)/);
if (!parts) {
return;
}
const sha256 = crypto.createHash('sha256').update(key).digest('hex');
const sha256 = crypto.createHash('sha256').update(lowerCaseKey).digest('hex');
const ownerAndRepo = parts[1].replace(/\.git$/, '');
fs.writeFileSync(`${homeSsh}/key-${sha256}`, key + "\n", { mode: '600' });
fs.writeFileSync(`${homeSsh}/key-${sha256}`, lowerCaseKey + "\n", { mode: '600' });
child_process.execSync(`git config --global --replace-all url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "https://github.com/${ownerAndRepo}"`);
child_process.execSync(`git config --global --add url."git@key-${sha256}.github.com:${ownerAndRepo}".insteadOf "git@github.com:${ownerAndRepo}"`);