diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts index 0306bb72e9..1b7852adcc 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/github.ts @@ -54,6 +54,7 @@ export class GithubPublisher implements PublisherBase { await pushToRemoteCred(directory, remoteUrl, { username: this.token, password: 'x-auth-basic', + token: this.token, }); return { remoteUrl }; diff --git a/plugins/scaffolder-backend/src/scaffolder/stages/publish/helpers.ts b/plugins/scaffolder-backend/src/scaffolder/stages/publish/helpers.ts index 61e76a31be..8e76649989 100644 --- a/plugins/scaffolder-backend/src/scaffolder/stages/publish/helpers.ts +++ b/plugins/scaffolder-backend/src/scaffolder/stages/publish/helpers.ts @@ -19,17 +19,28 @@ import globby from 'globby'; import fs from 'fs'; import http from 'isomorphic-git/http/node'; +/* +username password +GitHub | token 'x-oauth-basic' +GitHub App | token 'x-access-token' +BitBucket | 'x-token-auth' token +GitLab | 'oauth2' token +From : https://isomorphic-git.org/docs/en/onAuth +*/ export async function pushToRemoteCred( dir: string, remote: string, - auth?: { username: string; password: string }, + auth?: { username: string; password: string; token: string }, ): Promise { await git.init({ fs, dir, }); - const paths = await globby(['./**', './**/.*'], { gitignore: true }); + const paths = await globby(['./**', './**/.*'], { + cwd: dir, + gitignore: true, + }); for (const filepath of paths) { await git.add({ fs, dir, filepath }); } @@ -49,11 +60,15 @@ export async function pushToRemoteCred( url: remote, }); + console.warn({ username: auth.token, password: 'x-oauth-basic' }); await git.push({ fs, dir, http, + headers: { + 'user-agent': 'git/@isomorphic-git', + }, remote: 'origin', - onAuth: () => auth, + onAuth: () => ({ username: auth.token, password: 'x-oauth-basic' }), }); }