@@ -11,6 +11,7 @@ import {
11
11
configureGitHubAuthor ,
12
12
getOctokit ,
13
13
setVerbose ,
14
+ gitBranchExists ,
14
15
} from '../../common.js' ;
15
16
import { getNbGitDiff } from '../utils.js' ;
16
17
@@ -41,6 +42,10 @@ async function pushToAlgoliaDoc(): Promise<void> {
41
42
) ;
42
43
await fsp . rm ( tempGitDir , { force : true , recursive : true } ) ;
43
44
await run ( `git clone --depth 1 ${ githubURL } ${ tempGitDir } ` ) ;
45
+ if ( await gitBranchExists ( targetBranch , tempGitDir ) ) {
46
+ await run ( `git fetch origin ${ targetBranch } ` , { cwd : tempGitDir } ) ;
47
+ await run ( `git push -d origin ${ targetBranch } ` , { cwd : tempGitDir } ) ;
48
+ }
44
49
await run ( `git checkout -B ${ targetBranch } ` , { cwd : tempGitDir } ) ;
45
50
46
51
const pathToSpecs = toAbsolutePath ( `${ tempGitDir } /app_data/api/specs` ) ;
@@ -58,7 +63,7 @@ async function pushToAlgoliaDoc(): Promise<void> {
58
63
59
64
await configureGitHubAuthor ( tempGitDir ) ;
60
65
61
- const message = 'feat(clients): automatic update from api-clients-automation repository ' ;
66
+ const message = 'feat: update specs and supported versions ' ;
62
67
await run ( 'git add .' , { cwd : tempGitDir } ) ;
63
68
await gitCommit ( {
64
69
message,
@@ -81,6 +86,15 @@ async function pushToAlgoliaDoc(): Promise<void> {
81
86
head : targetBranch ,
82
87
} ) ;
83
88
89
+ await octokit . issues . createComment ( {
90
+ owner : OWNER ,
91
+ repo : repository ,
92
+ issue_number : data . number ,
93
+ body : [
94
+ `[**Preview SLA changes→**](https://deploy-preview-${ data . number } --algolia-docs.netlify.app/doc/libraries/supported-versions/)` ,
95
+ ] . join ( '\n\n' ) ,
96
+ } ) ;
97
+
84
98
console . log ( `Pull request created on ${ OWNER } /${ repository } ` ) ;
85
99
console . log ( ` > ${ data . url } ` ) ;
86
100
}
0 commit comments