@@ -4,6 +4,7 @@ import path, { resolve } from 'path';
44import {
55 CLIENTS ,
66 configureGitHubAuthor ,
7+ ensureGitHubToken ,
78 exists ,
89 getOctokit ,
910 gitBranchExists ,
@@ -113,6 +114,8 @@ async function handleGuideFiles(guide: GuidesToPush, tempGitDir: string): Promis
113114}
114115
115116async function pushToRepository ( repository : string , config : RepositoryConfiguration ) : Promise < void > {
117+ const token = ensureGitHubToken ( ) ;
118+
116119 const lastCommitMessage = await run ( 'git log -1 --format="%s"' ) ;
117120 const author = ( await run ( 'git log -1 --format="Co-authored-by: %an <%ae>"' ) ) . trim ( ) ;
118121 const coAuthors = ( await run ( 'git log -1 --format="%(trailers:key=Co-authored-by)"' ) )
@@ -129,10 +132,19 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
129132 console . log ( `Preparing push to ${ OWNER } /${ repository } ` ) ;
130133
131134 const tempGitDir = resolve ( process . env . RUNNER_TEMP ! || toAbsolutePath ( 'foo/local/test' ) , repository ) ;
135+
136+ console . info ( `cleaning ${ tempGitDir } ` ) ;
137+
132138 await fsp . rm ( tempGitDir , { force : true , recursive : true } ) ;
133139
140+ console . info ( `cloning ${ OWNER } /${ repository } in ${ tempGitDir } ` ) ;
141+
134142 await run ( `gh repo clone ${ OWNER } /${ repository } ${ tempGitDir } ` ) ;
135143
144+ await configureGitHubAuthor ( tempGitDir ) ;
145+
146+ await run ( `git config --global url.https://${ token } @github.com/.insteadOf https://github.com/` ) ;
147+
136148 for ( const task of config . tasks ) {
137149 console . log ( `Handling '${ task . files . type } ' file(s)` ) ;
138150
@@ -146,7 +158,7 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
146158 await handleGuideFiles ( task . files , tempGitDir ) ;
147159 }
148160
149- if ( process . env . DRYRUN ) {
161+ if ( process . env . DRY_RUN ) {
150162 console . log ( `asked for a dry run, stopping before push and PR for '${ repository } ' on task '${ task . prBranch } '` ) ;
151163
152164 continue ;
@@ -163,8 +175,6 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
163175 continue ;
164176 }
165177
166- await configureGitHubAuthor ( tempGitDir ) ;
167-
168178 await run ( 'git add .' , { cwd : tempGitDir } ) ;
169179 await gitCommit ( {
170180 message : task . commitMessage ,
0 commit comments