@@ -2,8 +2,8 @@ import fsp from 'fs/promises';
2
2
import path , { resolve } from 'path' ;
3
3
4
4
import {
5
+ CLIENTS ,
5
6
configureGitHubAuthor ,
6
- ensureGitHubToken ,
7
7
exists ,
8
8
getOctokit ,
9
9
gitBranchExists ,
@@ -22,16 +22,45 @@ import { getClientsConfigField } from '../../config.ts';
22
22
import { commitStartRelease } from './text.ts' ;
23
23
24
24
async function handleSpecFiles ( spec : SpecsToPush , tempGitDir : string ) : Promise < void > {
25
- const pathToSpecs = toAbsolutePath ( `${ tempGitDir } /${ spec . output } ` ) ;
26
-
27
- await run ( `cp ${ toAbsolutePath ( 'specs/bundled/README.md' ) } ${ pathToSpecs } ` ) ;
28
- await run ( `cp ${ toAbsolutePath ( 'specs/major-breaking-changes-rename.json' ) } ${ pathToSpecs } ` ) ;
29
- await run ( `cp ${ toAbsolutePath ( 'config/clients.config.json' ) } ${ pathToSpecs } ` ) ;
30
- await run ( `cp ${ toAbsolutePath ( 'docs/bundled/*.json' ) } ${ pathToSpecs } ` ) ;
31
- await run ( `cp ${ toAbsolutePath ( 'docs/bundled/*.yml' ) } ${ pathToSpecs } ` ) ;
32
- await run ( `cp ${ toAbsolutePath ( 'docs/versions-history-with-sla-and-support-policy.json' ) } ${ pathToSpecs } ` ) ;
25
+ const output = toAbsolutePath ( `${ tempGitDir } /${ spec . output } ` ) ;
26
+
27
+ if ( spec . includeSnippets ) {
28
+ await run ( `cp ${ toAbsolutePath ( 'docs/bundled/*-snippets.json' ) } ${ output } ` ) ;
29
+ }
30
+
31
+ if ( spec . includeSLA ) {
32
+ await run ( `cp ${ toAbsolutePath ( 'specs/bundled/README.md' ) } ${ output } ` ) ;
33
+ await run ( `cp ${ toAbsolutePath ( 'specs/major-breaking-changes-rename.json' ) } ${ output } ` ) ;
34
+ await run ( `cp ${ toAbsolutePath ( 'config/clients.config.json' ) } ${ output } ` ) ;
35
+ await run ( `cp ${ toAbsolutePath ( 'docs/versions-history-with-sla-and-support-policy.json' ) } ${ output } ` ) ;
36
+ }
37
+
33
38
// adblock extensions ban words like `analytics` so we use a different file name just so the doc dans render it
34
- await run ( `mv ${ pathToSpecs } /analytics.yml ${ pathToSpecs } /searchstats.yml` ) ;
39
+ if ( spec . ext === 'yml' ) {
40
+ await run ( `mv ${ output } /analytics.yml ${ output } /searchstats.yml` ) ;
41
+ }
42
+
43
+ for ( const client of CLIENTS ) {
44
+ const pathToBundledSpec = toAbsolutePath ( `docs/bundled/${ client } .${ spec . ext } ` ) ;
45
+
46
+ if ( ! ( await exists ( pathToBundledSpec ) ) ) {
47
+ continue ;
48
+ }
49
+
50
+ const outputFile = `${ output } /${ client } .${ spec . ext } ` ;
51
+
52
+ await run ( `cp ${ pathToBundledSpec } ${ outputFile } ` ) ;
53
+
54
+ if ( spec . placeholderVariables ) {
55
+ let file = await fsp . readFile ( outputFile , 'utf8' ) ;
56
+
57
+ for ( const [ k , v ] of Object . entries ( spec . placeholderVariables ) ) {
58
+ file = file . replace ( k , v ) ;
59
+ }
60
+
61
+ await fsp . writeFile ( outputFile , file ) ;
62
+ }
63
+ }
35
64
}
36
65
37
66
async function handleGuideFiles ( guide : GuidesToPush , tempGitDir : string ) : Promise < void > {
@@ -80,8 +109,6 @@ async function handleGuideFiles(guide: GuidesToPush, tempGitDir: string): Promis
80
109
}
81
110
82
111
async function pushToRepository ( repository : string , config : RepositoryConfiguration ) : Promise < void > {
83
- const githubToken = ensureGitHubToken ( ) ;
84
-
85
112
const lastCommitMessage = await run ( 'git log -1 --format="%s"' ) ;
86
113
const author = ( await run ( 'git log -1 --format="Co-authored-by: %an <%ae>"' ) ) . trim ( ) ;
87
114
const coAuthors = ( await run ( 'git log -1 --format="%(trailers:key=Co-authored-by)"' ) )
@@ -100,8 +127,7 @@ async function pushToRepository(repository: string, config: RepositoryConfigurat
100
127
const tempGitDir = resolve ( process . env . RUNNER_TEMP ! || toAbsolutePath ( 'foo/local/test' ) , repository ) ;
101
128
await fsp . rm ( tempGitDir , { force : true , recursive : true } ) ;
102
129
103
- const githubURL = `https://${ githubToken } :${ githubToken } @github.com/${ OWNER } /${ repository } ` ;
104
- await run ( `git clone --depth 1 ${ githubURL } ${ tempGitDir } ` ) ;
130
+ await run ( `gh repo clone ${ OWNER } /${ repository } ${ tempGitDir } ` ) ;
105
131
106
132
for ( const task of config . tasks ) {
107
133
await run ( `git checkout ${ config . baseBranch } ` , { cwd : tempGitDir } ) ;
0 commit comments