Skip to content

Commit

Permalink
Merge branch 'main' into fix/ingestion-specs-search
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts authored Aug 7, 2024
2 parents 2afceb4 + c702686 commit 585e940
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
16 changes: 15 additions & 1 deletion scripts/ci/codegen/pushToAlgoliaDoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
configureGitHubAuthor,
getOctokit,
setVerbose,
gitBranchExists,
} from '../../common.js';
import { getNbGitDiff } from '../utils.js';

Expand Down Expand Up @@ -41,6 +42,10 @@ async function pushToAlgoliaDoc(): Promise<void> {
);
await fsp.rm(tempGitDir, { force: true, recursive: true });
await run(`git clone --depth 1 ${githubURL} ${tempGitDir}`);
if (await gitBranchExists(targetBranch, tempGitDir)) {
await run(`git fetch origin ${targetBranch}`, { cwd: tempGitDir });
await run(`git push -d origin ${targetBranch}`, { cwd: tempGitDir });
}
await run(`git checkout -B ${targetBranch}`, { cwd: tempGitDir });

const pathToSpecs = toAbsolutePath(`${tempGitDir}/app_data/api/specs`);
Expand All @@ -58,7 +63,7 @@ async function pushToAlgoliaDoc(): Promise<void> {

await configureGitHubAuthor(tempGitDir);

const message = 'feat(clients): automatic update from api-clients-automation repository';
const message = 'feat: update specs and supported versions';
await run('git add .', { cwd: tempGitDir });
await gitCommit({
message,
Expand All @@ -81,6 +86,15 @@ async function pushToAlgoliaDoc(): Promise<void> {
head: targetBranch,
});

await octokit.issues.createComment({
owner: OWNER,
repo: repository,
issue_number: data.number,
body: [
`[**Preview SLA changes&rarr;**](https://deploy-preview-${data.number}--algolia-docs.netlify.app/doc/libraries/supported-versions/)`,
].join('\n\n'),
});

console.log(`Pull request created on ${OWNER}/${repository}`);
console.log(` > ${data.url}`);
}
Expand Down
4 changes: 2 additions & 2 deletions scripts/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ async function buildCustomGenerators(): Promise<void> {
spinner.succeed();
}

export async function gitBranchExists(branchName: string): Promise<boolean> {
return Boolean(await run(`git ls-remote --heads origin ${branchName}`));
export async function gitBranchExists(branchName: string, cwd?: string): Promise<boolean> {
return Boolean(await run(`git ls-remote --heads origin ${branchName}`, { cwd }));
}

export async function emptyDirExceptForDotGit(dir: string): Promise<void> {
Expand Down

0 comments on commit 585e940

Please sign in to comment.